UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.testImgV.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(100,100)];
CAShapeLayer *layer = [[CAShapeLayer alloc] init];
layer.frame = self.testImgV.bounds;
layer.path = path.CGPath;
self.testImgV.layer.mask = layer;
+ (instancetype)bezierPathWithRoundedRect:(CGRect)rect byRoundingCorners:(UIRectCorner)corners cornerRadii:(CGSize)cornerRadii;
//上述方法中的corner参数设置需要变化的角
typedef NS_OPTIONS(NSUInteger, UIRectCorner) {
UIRectCornerTopLeft = 1 << 0, //上左
UIRectCornerTopRight = 1 << 1, //上右
UIRectCornerBottomLeft = 1 << 2, //下左
UIRectCornerBottomRight = 1 << 3, //下右
UIRectCornerAllCorners = ~0UL
};
网友评论