[英]Setting corner radius without clipsToBounds works only for UIView type?
I have a UIView for which I set a cornerRadius property alone.我有一个 UIView ,我单独为其设置了一个cornerRadius 属性。 The UIView updates its corners. UIView 更新了它的角落。 But say I have a UILabel for which I set cornerRadius property alone without clipsToBounds, it does not work.但是假设我有一个 UILabel,我为它单独设置了没有 clipsToBounds 的cornerRadius 属性,它不起作用。 Both are of type UIView, then why does it not work for UILabel两者都是 UIView 类型,那么为什么它不适用于 UILabel
Internally , UILabel
has more than one layer ... UIView
does not.在内部, UILabel
不止一层...... UIView
没有。
You can use either:您可以使用:
myLabel.clipsToBounds = true
or或者
myLabel.layer.masksToBounds = true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.