Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //改变图片颜色
- - (UIImage *)imageWithColor:(UIColor *)color
- {
- UIGraphicsBeginImageContextWithOptions(self.size, NO, self.scale);
- CGContextRefcontext = 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement