ios-给view添加部分圆角
2020-07-17 本文已影响0人
songjk
以下例子为左上角和右上角添加圆角
CGFloat radius = 10; // 圆角大小
UIRectCorner corner = UIRectCornerTopLeft | UIRectCornerTopRight; // 圆角位置
UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:self.imgView.bounds byRoundingCorners:corner cornerRadii:CGSizeMake(radius, radius)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.imgView.bounds;
maskLayer.path = path.CGPath;
self.imgView.layer.mask = maskLayer;