设置UIView圆角 部分圆角
2014-05-22 11:11
435 查看
.h文件
</pre><pre code_snippet_id="357860" snippet_file_name="blog_20140522_1_4615163" name="code" class="objc">@interface UIView (RectCorner) - (void)setCornerOnTop; - (void)setCornerOnBottom; - (void)setAllCorner; - (void)setNoneCorner; @end
.m 文件
</pre><pre>
@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
转载自:http://blog.csdn.net/reylen/article/details/22038607
相关文章推荐
- UIView部分圆角设置
- UIView如何设置部分圆角
- UIView边框,圆角 透明 设置
- UIView 设置圆角
- iOS_给uiview等设置圆角
- 设置UIView圆角的拓展
- UIView,UIButton,UIImageView等设置圆角,设置阴影,设置边框的方法
- ios中如何将UIView设置为圆角
- 设置UIview的圆角效果
- UIView设置圆角、边框和阴影
- UIView设置成圆角
- UIVIEW圆角和边框设置
- 通过设置UIView得layer实现圆角矩形
- IOS设置UIView的边框为圆角
- 设置uiview圆角与阴影
- UIView的圆角设置
- 设置uiView,成圆角矩形
- 设置UIImage或UIView圆角 、设置UIView边框的代码
- 设置UIView为圆角矩形
- UIView 设置圆角