设置UIView圆角的拓展

来源:互联网 发布:js求两个集合的并集 编辑:程序博客网 时间:2024/05/19 09:16
@interface UIView (RectCorner)@end@implementation UIView (RectCorner)- (void)setCornerOnTop {    UIBezierPath *maskPath;    maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds                                     byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight)                                           cornerRadii:CGSizeMake(10.0f, 10.0f)];    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];    maskLayer.frame = self.bounds;    maskLayer.path = maskPath.CGPath;    self.layer.mask = maskLayer;    [maskLayer release];}- (void)setCornerOnBottom {    UIBezierPath *maskPath;    maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds                                     byRoundingCorners:(UIRectCornerBottomLeft | UIRectCornerBottomRight)                                           cornerRadii:CGSizeMake(10.0f, 10.0f)];    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];    maskLayer.frame = self.bounds;    maskLayer.path = maskPath.CGPath;    self.layer.mask = maskLayer;    [maskLayer release];}- (void)setAllCorner {    UIBezierPath *maskPath;    maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds                                          cornerRadius:10.0];    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];    maskLayer.frame = self.bounds;    maskLayer.path = maskPath.CGPath;    self.layer.mask = maskLayer;    [maskLayer release];}- (void)setNoneCorner{    self.layer.mask = nil;}@end




0 0