iOS更改图片颜色
作者:
Sh1mmer | 来源:发表于
2019-07-15 16:53 被阅读0次- (UIImage*)imageChangeColor:(UIColor*)color image:(UIImage *)image{
//获取画布
UIGraphicsBeginImageContextWithOptions(image.size, NO, 0.0f);
//画笔沾取颜色
[color setFill];
CGRect bounds = CGRectMake(0, 0, image.size.width, image.size.height);
UIRectFill(bounds);
//绘制一次
[image drawInRect:bounds blendMode:kCGBlendModeOverlay alpha:1.0f];
//再绘制一次
[image drawInRect:bounds blendMode:kCGBlendModeDestinationIn alpha:1.0f];
//获取图片
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return img;
}
本文标题:iOS更改图片颜色
本文链接:https://www.haomeiwen.com/subject/mdwnkctx.html
网友评论