通过UIRectCorner
和 UIBezierPath
组合给进行设置
// cornerRadius圆角大小,cornerRadius指定角
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(cornerRadius, cornerRadius)];
maskLayer.maskLayer.frame = self.bounds;
maskLayer.path = maskPath.CGPath;
self.layer.mask = maskLayer;
网友评论