给UIView切任意圆角

2016-05-12  本文已影响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];

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


上一篇 下一篇

猜你喜欢

热点阅读