美文网首页
UIView指定角为圆角

UIView指定角为圆角

作者: 啪嗒嗒 | 来源:发表于2016-02-17 17:37 被阅读37次

代码:

UIView *one = [[UIView alloc]initWithFrame:CGRectMake(100, 200, 200, 200)];
one.backgroundColor = [UIColor colorWithRed:0.000 green:0.502 blue:1.000 alpha:1.000];
[self.view addSubview:one];
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:one.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(20, 0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc]init];
maskLayer.frame = one.bounds;
maskLayer.path = maskPath.CGPath;
one.layer.mask = maskLayer;

效果图:

2222.png

相关文章

网友评论

      本文标题:UIView指定角为圆角

      本文链接:https://www.haomeiwen.com/subject/tgrmkttx.html