I want to add multiple shadows to a label. Red shadow and blue shadow. But my code doesn’t work. I see only blue shadow.
private lazy var titleLabel: UILabel = {
let label = UILabel()
label.textColor = .black
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
override func viewDidLoad() {
super.viewDidLoad()
titleLabel.text = "1"
addDropShadow(color: UIColor.red, offset: CGSize(width: -6, height: -6), btnLayer: titleLabel.layer)
addDropShadow(color: UIColor.blue, offset: CGSize(width: 6, height: 6), btnLayer: titleLabel.layer)
}
private func addDropShadow(color: UIColor, offset: CGSize, btnLayer : CALayer) {
btnLayer.masksToBounds = false
btnLayer.shadowColor = color.cgColor
btnLayer.shadowOpacity = 1
btnLayer.shadowOffset = offset
btnLayer.shadowRadius = 10
}