IOS image masking

I would like to take a picture and use it as a mask for a view in which I add numerous kinds of images. I know about the quartz call to CGContextClipToMask (), but what would be the best way to approach this? Can I override the drawRect method in the container view, call CGContextClipToMask () in it, and then expect its sub items to adhere to this clipping area? This does not seem to work.

Do I need to add a mask mask image on top instead?

+3
source share
1 answer

Instead of subclassing or overriding the drawing functions, I decided to overlay images on the image with transparency in the visible part. those. if my "surface" was an image of parchment, and I intended to draw a bunch of images on it. I will have a parchment image, then a UIView container for any images that will be placed on this parchment, then a mask image on top of that which was the original parchment image, but with parchment converted instead to full transparency, and the surrounding area remains exactly as the background on which the parchment is on (then all the other widgets of the user interface on top of this).

, , - ( ).

+1

Source: https://habr.com/ru/post/1794935/


All Articles