将UIBezierPath添加到UILabel大小后不会根据设备而改变吗?

问题描述 投票:0回答:1

我的代码

-(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];

enter image description here

此处尾随空格比起前导空格要多。

圆角图像的前导和尾随应相同。如何设置?

ios objective-c xcode cocoa-touch uibezierpath
1个回答
0
投票

您可以如下添加宽度

[CAShapeLayer *图层= [CAShapeLayer新];]]

layer.lineWidth = 4; //在这里添加

建议处理高度的方法是在1以上希望这对您有帮助

© www.soinside.com 2019 - 2024. All rights reserved.