いくつかの透明なピクセルを含む画像がある場合、透明なピクセルを白で色付けし、目的の c で残りの画像を透明にする可能性はありますか?
ありがとう!
いくつかの透明なピクセルを含む画像がある場合、透明なピクセルを白で色付けし、目的の c で残りの画像を透明にする可能性はありますか?
ありがとう!
これが私が使用しているものです:
- (UIImage *)imageWithTintedColor:(UIImage *)image withTint:(UIColor *)color withIntensity:(float)alpha
{
CGSize size = image.size;
UIGraphicsBeginImageContextWithOptions(size, FALSE, [[UIScreen mainScreen] scale]);
CGContextRef context = UIGraphicsGetCurrentContext();
[image drawAtPoint:CGPointZero blendMode:kCGBlendModeNormal alpha:1.0];
CGContextSetFillColorWithColor(context, color.CGColor);
CGContextSetBlendMode(context, kCGBlendModeSourceAtop);
CGContextSetAlpha(context, alpha);
CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(CGPointZero.x, CGPointZero.y, image.size.width, image.size.height));
UIImage * tintedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return tintedImage;
}