我的代码
-(void)roundCornersWithCorner:(UIRectCorner)corners andRadius:(CGFloat)radius withView:(UILabel *)lable
{
CAShapeLayer * maskLayer = [CAShapeLayer layer];
maskLayer.path = [UIBezierPath bezierPathWithRoundedRect:lable.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(radius, radius)].CGPath;
lable.layer.mask = maskLayer;
[[lable layer] setShadowOffset:CGSizeMake(0, -2)];
[[lable layer] setShadowOpacity:0.5f];
[[lable layer] setShadowRadius:2.0f];
}
调用功能:
[self roundCornersWithCorner: UIRectCornerTopLeft | UIRectCornerTopRight andRadius:12 withView:myLabel];
此处尾随空格比起前导空格要多。
圆角图像的前导和尾随应相同。如何设置?
您可以如下添加宽度
[CAShapeLayer *图层= [CAShapeLayer新];]]
layer.lineWidth = 4; //在这里添加
建议处理高度的方法是在1以上希望这对您有帮助