i'm looking for a way to display a UILabel
with layer.cornerRadius
and layer.shadow
.
I figured out, that with label.clipsToBounds = true
the cornerRadius
will be set and with label.masksToBounds = false
the shadow will be displayed
With both only the shadow, without the cornerRadius will be displayed
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"
Can anyone solve this, so that the cornerRadius
AND the shadow
will be displayed?