设置UIView圆角的拓展
2014-03-25 09:42
120 查看
@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圆角的拓展
- iphone中,在编辑文本时怎么设置UITextView的边框颜色?
- 为UIView及其子类添加圆角边框
- How To Build Your First F**king STAF Service
- 1 IntelliSense: #error 指令: Please use the /MD switch for _AFXDLL builds
- UVa540 Team Queue
- WinCE MUI的实现
- NGUI如何使用汉字
- WINCE 6.0编译西班牙语UI,葡萄牙语UI
- iOS UIActionSheet的使用
- ARDUINO 串口回显数据
- Permutation Sequence -- LeetCode
- NSBundle控件和UIImageView和UIButton区别
- Android4.2.2 SurfaceFlinger之图形缓存区申请与分配dequeueBuffer
- Android4.2.2 SurfaceFlinger之Layer和Bufferqueue的创建过程
- emctl start dbconsole遇到错误:OC4J Configuration issue
- ios 中的UI控件学习总结(1)
- LeetCode Unique Binary Search Trees
- 错误:org.hibernate.PropertyValueException: not-null property references a null
- rebuild online意外终止导致ora-8104错误的实验