I am trying to create an ImageView
that has rounded corners and a shadow to give it some depth. I was able to create a shadow for the UIImageView
, but whenever I added the code to also make it have rounded corners, it only had rounded corners with no shadow. I have an IBOutlet
named myImage
, and it is inside of the viewDidLoad
function. Does anybody have any ideas on how to make it work? What am I doing wrong?
override func viewDidLoad() {
super.ViewDidLoad()
myImage.layer.shadowColor = UIColor.black.cgColor
myImage.layer.shadowOpacity = 1
myImage.layer.shadowOffset = CGSize.zero
myImage.layer.shadowRadius = 10
myImage.layer.shadowPath = UIBezierPath(rect: myImage.bounds).cgPath
myImage.layer.shouldRasterize = false
myImage.layer.cornerRadius = 10
myImage.clipsToBounds = true
}
clipsToBounds = true
you will never be able to see a shadow that goes beyond the bounds. – DreadfulmyImage
inside of another view that isn't clipping its bounds and apply the shadow to that view. – DreadfulmyImage
inside of a new UIView that isn't clipping its corners and has a shadow ?? – Huntingdon