我的代码
-(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];
这里的尾部空格比起前导的空格要多。
圆角图像的前导和尾随应相同。如何设置?