iOS-UIImage图片绘制颜色

时间:2021-06-25 08:56:05
- (UIImage *)dtk_setImageColor:(UIColor *)imageColor{
//获取画布
UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0f);
//画笔沾取颜色
[imageColor setFill];
CGRect bounds = CGRectMake(, , self.size.width, self.size.height);
//绘制一次
UIRectFill(bounds);
//再绘制一次
[self drawInRect:bounds blendMode:kCGBlendModeOverlay alpha:1.0f];
//获取图片
[self drawInRect:bounds blendMode:kCGBlendModeDestinationIn alpha:1.0f];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}