ios view切除指定的角

```
UIView*view2=[[UIViewalloc]initWithFrame:CGRectMake(120,10,80,80)];

view2.backgroundColor=[UIColorredColor];[self.viewaddSubview:view2];

UIBezierPath*maskPath=[UIBezierPathbezierPathWithRoundedRect:view2.boundsbyRoundingCorners:UIRectCornerBottomLeft|UIRectCornerBottomRightcornerRadii:CGSizeMake(10,10)];

CAShapeLayer*maskLayer=[[CAShapeLayeralloc]init];

maskLayer.frame=view2.bounds;maskLayer.path=maskPath.CGPath;view2.layer.mask=maskLayer;

```
其中byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight指定了需要成为圆角的角。该参数是UIRectCorner类型的,可选的值有* UIRectCornerTopLeft* UIRectCornerTopRight* UIRectCornerBottomLeft* UIRectCornerBottomRight* UIRectCornerAllCorners从名字很容易看出来代表的意思,使用“|”来组合就好了。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容