// 左上和右上为圆角
UIBezierPath *cornerRadiusPath = [UIBezierPath bezierPathWithRoundedRect:self.teLabel.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerTopLeft cornerRadii:CGSizeMake(5, 5)];
CAShapeLayer *cornerRadiusLayer = [ [CAShapeLayer alloc] init];
cornerRadiusLayer.frame = self.teLabel.bounds;
cornerRadiusLayer.path = cornerRadiusPath.CGPath;
self.teLabel.layer.mask = cornerRadiusLayer;
要设置其他角的圆角,可以修改byRoundingCorners:
UIRectCornerTopLeft = 1 << 0, // 左上
UIRectCornerTopRight = 1 << 1, // 右上
UIRectCornerBottomLeft = 1 << 2, // 左下
UIRectCornerBottomRight = 1 << 3, // 右下
本文详细介绍了如何使用UIBezierPath和CAShapeLayer在iOS应用中为UILabel设置特定角落的圆角效果。通过修改byRoundingCorners参数,可以轻松实现左上、右上、左下或右下角的圆角定制。
4403

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



