I believe you can do this using the kCGBlendModeDestinationOut blending kCGBlendModeDestinationOut . Create a new context, draw a background image, then draw a foreground image in this blend mode.
UIGraphicsBeginImageContextWithOptions(sourceImage.size, NO, sourceImage.scale) [sourceImage drawAtPoint:CGPointZero]; [maskImage drawAtPoint:CGPointZero blendMode:kCGBlendModeDestinationOut alpha:1.0f]; UIImage *result = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext();
Lily ballard
source share