我正在寻找一种方法来显示带有
我发现,使用
使用两者时,只会显示阴影,而没有圆角。
layer.cornerRadius
和layer.shadow
的UILabel
。我发现,使用
label.clipsToBounds = true
可以设置cornerRadius
,而使用label.masksToBounds = false
则可以显示阴影。使用两者时,只会显示阴影,而没有圆角。
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
?
label label = UILabel()
还是let label = UILabel()
? - Wings