I have this method which I created after hooking into SBAwayView:
- (UIImage *) colorizeImage:(UIImage *)img color:(UIColor *)color{
NSString *name = @"badge.png";
UIImage *img = [UIImage imageNamed:name];
UIGraphicsBeginImageContext(img.size);
CGContextRef context = UIGraphicsGetCurrentContext();
[color setFill];
CGContextTranslateCTM(context, 0, img.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextSetBlendMode(context, kCGBlendModeColorBurn);
CGRect rect = CGRectMake(0, 0, img.size.width, img.size.height);
CGContextDrawImage(context, rect, img.CGImage);
CGContextClipToMask(context, rect, img.CGImage);
CGContextAddRect(context, rect);
CGContextDrawPath(context,kCGPathFill);
UIImage *coloredImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return coloredImg;
}
But when I send it the color
[[UIColor alloc] initWith开发者_Go百科Red:0.0 green:0.0 blue:1.0 alpha:1.0];
and an image it just returns it as completely blackened!
精彩评论