CGImage Masking with UIImage pngData()
问题 I'm trying to mask an image in swift. Here's my code: (Normally, originalImg is an image that is loaded from UIImagePickerController and then cropped by UIGraphicsGetImageFromCurrentImageContext() , and makedImage is an image that is drawn by the user, created by UIGraphicsGetImageFromCurrentImageContext() ) func imageMasking(_ originalImg: UIImage, maskImage: UIImage) -> UIImage { let cgMaskImage = maskImage.cgImage! let mask = CGImage(maskWidth: cgMaskImage.width, height: cgMaskImage.height