Created
April 1, 2017 17:44
-
-
Save iOSDigital/77f6652756cdc292a8ec4960658f55d8 to your computer and use it in GitHub Desktop.
invertedImageWithColor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(UIImage *)invertedImageWithColor:(UIColor*)color { | |
UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0); | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
CGRect contextRect = CGContextGetClipBoundingBox(context); | |
CGContextSetFillColorWithColor(context, [color CGColor]); | |
CGContextFillRect(context, contextRect); | |
[self drawInRect:contextRect blendMode:kCGBlendModeDestinationOut alpha:1.0]; | |
UIImage *invertedImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return invertedImage; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment