Mik*_*e V 181 cornerradius uiview uilabel ios ios7
我目前正在寻找具有属性的UILabel addMessageLabel.layer.cornerRadius = 5.0f;
在安装了iOS 7.0的设备上,它有圆角.在安装了iOS 7.1的设备上,它没有圆角.
这只是iOS 7.1的一个错误吗?
Rah*_*diq 474
将该属性设置clipsToBounds
为true
addMessageLabel.clipsToBounds = true
Run Code Online (Sandbox Code Playgroud)
Tap*_*Pal 22
添加以下两行并检查它.
[[addMessageLabel layer] setCornerRadius:5.0f];
[[addMessageLabel layer] setMasksToBounds:YES];
Run Code Online (Sandbox Code Playgroud)
要么
[addMessageLabel setClipsToBounds:YES];
Run Code Online (Sandbox Code Playgroud)
我的问题有点不同。
当我做的时候 btn.clipsToBounds = true
我没有打算这样做:
btn.layer.cornerRadius = 20
Run Code Online (Sandbox Code Playgroud)
因为我的屏幕尺寸不同。相反,我遵循了这个答案并做了:
override func layoutSubviews() {
seeMoreButton.layer.cornerRadius = seeMoreButton.bounds.size.height / 2
}
Run Code Online (Sandbox Code Playgroud)
这没用,因为我忘了加super.layoutSubviews()
。正确的代码是:
override func layoutSubviews() {
super.layoutSubviews()
seeMoreButton.layer.cornerRadius = seeMoreButton.bounds.size.height / 2
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
71255 次 |
最近记录: |