R = D*Sa
:目标色 = 原色*目标色的透明度
R
--result
S
--原色
D
--目标色
Ra
、Sa
、Da
分别为三种颜色的透明度
- (UIImage *)changImageColorWithImage:(UIImage *)image color:(UIColor *)targetColor blendModel:(CGBlendMode)mode
{
//获取画布
UIGraphicsBeginImageContext(image.size);
//画笔沾取颜色
[targetColor setFill];
CGRect drawRect = CGRectMake(0, 0, image.size.width, image.size.height);
UIRectFill(drawRect);
[image drawInRect:drawRect blendMode:mode alpha:1];
//获取图片
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}