设置UIView圆角的拓展
2016-05-20 09:42
495 查看
@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
@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
相关文章推荐
- Kendo UI常用示例汇总(九)
- 通过UIKit坐标系来全面掌握iOS中的UIScrollView组件
- 2014年12月1日 量产U+B+高端隐藏 UD(U深)三分区和分区表项,支持bios/uefi启动
- Vue.js-----轻量高效的MVVM框架(四、指令)
- UINavigation的常用问题解决方案
- 优先队列 priority_queue
- UITableView 自定义cell
- poj--1141 Brackets Sequence(dp)
- 解决easyui combobox 下拉高度大于实际值
- Auto inspection lot creation and Auto Usage decision for required parts
- Ant_的最完整build.xml解释
- 关于iOS的UI界面反向传值方法总结
- <compilation debug="true" targetFramework="4.0">的解决
- UIApplication的详细介绍
- Codeforces Round #333 (Div. 2) 602D. Lipshitz Sequence 单调栈
- querySelectorAll对象无ID的题
- GUI的使用总结
- StringBuilder和StringBuffer(转的)
- 一款自定义提示框AlertView(继承UIView)
- Build Boost 遇到错误