ios - How to add an overlay layer to a UIImageView but not on the transparent part of the image? -


i have uiimageview:

self.princessimageview.image = uiimage(named: "princess")! 

enter image description here

now trying add coloured layer alpha of 0.3 on image. 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 result.

enter image description here

i understand of course it's because i'm setting overlay on whole view. there way can set overlay on non-transparent part of image ?

thanks help.

you need play blending modes that.

apple documentation : link

some relevant stuff might : link1 link2


Comments

Popular posts from this blog

angular - DownloadURL return null in below code -

python 2.7 - Given three nested dictionaries, sort the top two nested dictionaries from a value in the innermost dictionary? -