I have this UIImageView
:
self.princessImageView.image = UIImage(named: "princess")!
Now I am trying to add a coloured layer with an alpha of 0.3 on this image. I tried this:
let overlayView: UIView = UIView(frame: CGRect(x: 0,
y: 0,
width: self.princessImageView.frame.size.width,
height: self.princessImageView.frame.size.height))
overlayView.backgroundColor = UIColor.blue.withAlphaComponent(0.3)
self.princessImageView.addSubview(overlayView)
But I'm getting this result.
I understand that of course it's because I'm setting an overlay on the whole view. Is there any way so I can set the overlay only on the non-transparent part of the image ?
Thanks for your help.