我正在寻找一种方式来显示UILabel
with layer.cornerRadius
and layer.shadow
.
我发现,与label.clipsToBounds = true
the cornerRadius
将被设置并与label.masksToBounds = false
将显示阴影
两者都只有阴影,没有cornerRadius会显示
let label = UILabel()
label.textAlignment = .center
label.font = UIFont.systemFont(ofSize: 32, weight: .regular)
label.textColor = .white
label.clipsToBounds = true
label.backgroundColor = Colors.Vibrants.softBlue
label.layer.cornerRadius = 50
label.layer.masksToBounds = false
label.layer.shadowColor = UIColor.black.cgColor
label.layer.shadowOffset = CGSize(width: 5, height: 5)
label.layer.shadowRadius = 5
label.layer.shadowOpacity = 0.7
label.text = "0"
任何人都可以解决这个问题,以便cornerRadius
和shadow
将会显示?
你为什么不尝试添加一个家长UIView
用于包含背景颜色和cornerRadius 的标签。然后保留标签的阴影属性
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)