- @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
设置UIView圆角的拓展
最新推荐文章于 2019-11-21 17:27:43 发布