Ios 在图像上叠加alpha颜色
我使用下面的代码将0.5 alpha颜色覆盖到UIImage上。但它似乎落后了。我的图像大小为2000x1500 有没有其他方法可以快速将alpha颜色叠加到UIImage上 谢谢Ios 在图像上叠加alpha颜色,ios,objective-c,uiimage,Ios,Objective C,Uiimage,我使用下面的代码将0.5 alpha颜色覆盖到UIImage上。但它似乎落后了。我的图像大小为2000x1500 有没有其他方法可以快速将alpha颜色叠加到UIImage上 谢谢 // Tint the image - (UIImage *)imageWithTint:(UIColor *)tintColor alpha:(CGFloat)alpha { UIImage *image = self; CGRect rect = CGRectMake(0, 0, image.si
// Tint the image
- (UIImage *)imageWithTint:(UIColor *)tintColor alpha:(CGFloat)alpha {
UIImage *image = self;
CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);
UIGraphicsBeginImageContextWithOptions(rect.size, NO, [UIScreen mainScreen].scale);
CGContextRef c = UIGraphicsGetCurrentContext();
[image drawInRect:rect];
CGContextSetFillColorWithColor(c, [[tintColor colorWithAlphaComponent:0.25] CGColor]);
CGContextSetBlendMode(c, kCGBlendModeSourceAtop);
CGContextFillRect(c, rect);
UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return result;
}
你为什么不在包含图像的UIImageView上放一个UIView呢?@FabioBerger,我需要实际修改的图像发送到服务器。