美文网首页
给UIView切任意圆角

给UIView切任意圆角

作者: 相逢不晚为何匆匆 | 来源:发表于2016-05-12 11:36 被阅读174次
//切圆角,封装了一个方法,网络上搜集到,方便自己使用

- (void)setMaskTo:(UIView*)view byRoundingCorners:(UIRectCorner)corners

{

UIBezierPath *rounded = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(8.0, 8.0)];

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

[shape setPath:rounded.CGPath];

view.layer.mask = shape;

}

//调用

[self setMaskTo:_infoView byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight];

可以切任意圆角,效果如图


相关文章

网友评论

      本文标题:给UIView切任意圆角

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