【发布时间】:2020-04-24 18:01:21
【问题描述】:
我有一个 UIView,我单独为其设置了一个cornerRadius 属性。 UIView 更新它的角。但是假设我有一个 UILabel,我为它单独设置了没有 clipsToBounds 的cornerRadius 属性,它不起作用。都是UIView类型的,那为什么UILabel不行呢
【问题讨论】:
标签: ios uiview label layer cornerradius
我有一个 UIView,我单独为其设置了一个cornerRadius 属性。 UIView 更新它的角。但是假设我有一个 UILabel,我为它单独设置了没有 clipsToBounds 的cornerRadius 属性,它不起作用。都是UIView类型的,那为什么UILabel不行呢
【问题讨论】:
标签: ios uiview label layer cornerradius
在内部,UILabel 有多个层...UIView 没有。
你可以使用:
myLabel.clipsToBounds = true
或
myLabel.layer.masksToBounds = true
【讨论】: