[self setMaskTo:yourView byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight];
- (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;
}
本文介绍了一种使用Objective-C为UIView设置特定圆角的方法。通过创建一个UIBezierPath并指定需要圆角化的角,然后将这个路径转换为CAShapeLayer,并将其设置为UIView的mask属性,以此实现对UIView特定角的圆角效果。

被折叠的 条评论
为什么被折叠?



