pngs with alpha channel and the masking demo code?

All,


i have the usual suspect of a png with a transparent background, the default view background is a square. I want to self mask so that the end image is a the shape of the original image without having to jump through redrawing everything, just bitmask it.


There is this demo code here

h ttps://developer.apple.com/library/content/samplecode/QuartzDemo/Listings/QuartzDemo_QuartzMaskingView_swift.html


this documentation

h ttps://developer.apple.com/library/content/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_images/dq_images.html


This seems like a lot of code to do something very simple. So is there some binary image function that does this without having to redraw?

If I'm understanding you correctly, you just want the image to be displayed without the view's background? If so you have two ways you could go


1) If you don't need to do any additional drawing, try just using UIImageView, which will display the image as is without any additional background (by default at least)

2) If you do need to do additional drawing, set your UIView's background color to [UIColor clearColor] and opaque=NO. Then you will draw over "clear" which won't add any additional background at that point.

pngs with alpha channel and the masking demo code?
 
 
Q