Skip to content

Instantly share code, notes, and snippets.

@ZhukV
Created April 24, 2015 06:16
Show Gist options
  • Save ZhukV/b797e3886e298766fd47 to your computer and use it in GitHub Desktop.
Save ZhukV/b797e3886e298766fd47 to your computer and use it in GitHub Desktop.
+ (UIImage *)imageNamedWithoutCache:(NSString *)imagePath withMask:(NSString *)maskPath
{
UIImage *realImage = [self imageNamedWithoutCache:imagePath];
UIImage *maskImage = [self imageNamedWithoutCache:maskPath];
CGImageRef maskRef = maskImage.CGImage;
CGImageRef mask = CGImageMaskCreate(CGImageGetWidth(maskRef),
CGImageGetHeight(maskRef),
CGImageGetBitsPerComponent(maskRef),
CGImageGetBitsPerPixel(maskRef),
CGImageGetBytesPerRow(maskRef),
CGImageGetDataProvider(maskRef), NULL, false);
CGImageRef masked = CGImageCreateWithMask([realImage CGImage], mask);
return [UIImage imageWithCGImage:masked];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment