Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在图像上叠加alpha颜色_Ios_Objective C_Uiimage - Fatal编程技术网

Ios 在图像上叠加alpha颜色

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

我使用下面的代码将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.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,我需要实际修改的图像发送到服务器。