I am trying make some shadow effect on my logo image but the effect is not showing off..
func setUpLogo(){
view.addSubview(logoView)
logoView.translatesAutoresizingMaskIntoConstraints = false
logoView.topAnchor.constraint(equalTo: view.topAnchor,constant: 220).isActive = true
logoView.widthAnchor.constraint(equalToConstant: 140).isActive = true
logoView.heightAnchor.constraint(equalToConstant: 190).isActive = true
logoView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
logoView.image = UIImage(named: "logoCharity")
logoView.layer.cornerRadius = 11
logoView.clipsToBounds = true
logoView.layer.shadowColor = UIColor.red.cgColor
logoView.layer.shadowOpacity = 1
logoView.layer.shadowOffset = CGSize(width: 0, height: 0)
logoView.layer.shadowRadius = 10
}
2
Answers
Can you try this one or change into logoView.clipsToBounds = false
Basically you cannot have both clipping corners and shadow overlapping the view bounds.
To achieve that, you need to have two views – one for clipping and one for the shadow.