iOS之任意圆角

例如给一个view加圆角:

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
CGFloat corner = 6;
CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.path = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft |   UIRectCornerTopRight | UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(corner, corner)].CGPath;
view.layer.mask = shapeLayer;

你可能感兴趣的:(iOS之任意圆角)