首页 > 移动平台 > 详细

iOS开发之指定UIView的某几个角为圆角

时间:2016-04-25 14:51:49      阅读:187      评论:0      收藏:0      [点我收藏+]

使用UIBezierPath。下面给出一段示例代码。

 1 UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(120, 10, 80, 80)];
 2 view2.backgroundColor = [UIColor redColor];
 3 [self.view addSubview:view2];
 4 
 5 UIBezierPath maskPath = [UIBezierPath bezierPathWithRoundedRect:view2.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];
 6 CAShapeLayer maskLayer = [[CAShapeLayer alloc] init];
 7 maskLayer.frame = view2.bounds;
 8 maskLayer.path = maskPath.CGPath;
 9 view2.layer.mask = maskLayer;
10 
11 
12 //指定了需要成为圆角的角。该参数是UIRectCorner类型的,可选的值有:
13 
14 * UIRectCornerTopLeft
15 * UIRectCornerTopRight
16 * UIRectCornerBottomLeft
17 * UIRectCornerBottomRight
18 * UIRectCornerAllCorners

 

iOS开发之指定UIView的某几个角为圆角

原文:http://www.cnblogs.com/helmsyy/p/5430686.html

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