- (UIImage *)imageWithColor:(UIColor *)color{
UIGraphicsBeginImageContextWithOptions(self.size, NO, self.scale);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, 0, self.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextSetBlendMode(context, kCGBlendModeNormal);
CGRect rect = CGRectMake(0, 0, self.size.width, self.size.height);
CGContextClipToMask(context, rect, self.CGImage);
[color setFill];
CGContextFillRect(context, rect);
UIImage*newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
Last active
July 12, 2018 05:18
-
-
Save liuzhida33/d3d3543f1e745c51ebd45a9b55e54651 to your computer and use it in GitHub Desktop.
iOS修改图片颜色
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment