【发布时间】:2018-09-04 10:36:30
【问题描述】:
有没有办法为 UILabel 的右上角和右下角设置cornerRadius?
我尝试了以下方法,但它根本不起作用,使用下面的代码我没有得到预期的输出。所以如果需要,任何人都可以在我的代码中进行更正吗?
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:lblCollectPaymentAmount.bounds
byRoundingCorners:(UIRectCornerTopRight | UIRectCornerBottomRight)
cornerRadii:CGSizeMake(5.0, 5.0)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = lblCollectPaymentAmount.bounds;
maskLayer.path = maskPath.CGPath;
lblCollectPaymentAmount.layer.mask = maskLayer;
lblCollectPaymentAmount.layer.masksToBounds = YES;
【问题讨论】:
-
您的代码运行良好。你检查你的标签背景颜色了吗
标签: ios objective-c uilabel uibezierpath rounded-corners