iOS圆角

1
2
self.btn.layer.masksToBounds=YES;
self.btn.layer.cornerRadius=self.btn.frame.size.width/2.0;

1
2
3
4
5
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.btn.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(self.btn.frame.size.width/2.0, self.btn.frame.size.width/2.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.btn.bounds;
maskLayer.path = maskPath.CGPath;
self.btn.layer.mask = maskLayer;