给UIView切任意圆角

给UIView切任意圆角

其中CGSizeMake(8.0, 8.0)的8.0是半径.


- (void)setMaskTo:(UIView*)view byRoundingCorners:(UIRectCorner)corners{
UIBezierPath *rounded = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(8.0, 8.0)];
CAShapeLayer *shape = [[CAShapeLayer alloc] init];
[shape setPath:rounded.CGPath];
view.layer.mask = shape;
}
//调用
[self setMaskTo:_infoView byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight];

你可能感兴趣的:(给UIView切任意圆角)