How to align a mask onto an image
问题 I'm writing in Swift, trying to mask an image using UIImage and CALayer. The problem is that the mask is scaled and shifted when applied to the image. I have created my UIImageViewer using the Interface Builder and I have set it to Aspect Fit. I would like to mask images of arbitrary size. I generate the mask image to be the same size as the image. This is a requirement because later I want to add more elements to my mask programmatically and it has to cover the masked image. Here's my code: