ios-给view添加部分圆角

以下例子为左上角和右上角添加圆角

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;

你可能感兴趣的:(ios-给view添加部分圆角)