首页 > 其他 > 详细

UIView圆角设置

时间:2015-11-20 19:12:19      阅读:213      评论:0      收藏:0      [点我收藏+]

对于UIview的圆角设置最简单的就是layer的两个属性分别是cornerRadius和masksToBounds,但是对于设置其中某一个角为圆角的时候需要使用贝塞尔曲线

UIView *aView = [[UIView alloc] init];

aView.frame = CGRectMake(0, 0, 300, 200);

aView.backgroundColor = [UIColor redColor];

[self.view addSubview:aView];

//设置所需的圆角位置以及大小 UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:aView.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];

CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];

maskLayer.frame = aView.bounds;

maskLayer.path = maskPath.CGPath;

aView.layer.mask = maskLayer;

其中UIRectCornerBottomLeft 和UIRectCornerBottomRight,是一个枚举,里面还包括左上角和右上角
但是再某些时候这么设置圆角,对于应用的来说会很占用资源,所以就要实现比较麻烦的贝塞尔曲线了。

UIView圆角设置

原文:http://www.cnblogs.com/Acee/p/4981667.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!