您的位置:首页 > 产品设计 > UI/UE

UIView的四个边角单独设置为圆角弧度

2015-02-13 16:27 766 查看
我们知道设置UIView的Layer的cornerRadius属性即可改变View的圆角。如果要单独设置某一个角或者2个,3个为圆角,就可以用下面方法。


UIView *view = [[UIView alloc] initWithFrame:CGRectMake(120, 100, 100, 100)];
view.backgroundColor = [UIColor blueColor];
[self.view addSubview:view];

UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(15, 15)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = view.bounds;
maskLayer.path = maskPath.CGPath;
view.layer.mask = maskLayer;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: