小编sur*_*eal的帖子

CGImageCreateWithMaskingColors不适用于iOS7

我在iOS5和iOS6上开发了一个应用程序.在我升级到XCode 5和iOS7后,我有一些新的bug.

主要的是colorMasking不再有效.完全相同的代码仍可编译并适用于iOS6手机.在iOS7上,蒙面颜色仍然存在.我试图在谷歌上找到答案,但还没找到答案.这是iOS7的错误,还是有人知道更好的做彩色掩模的方法?

这是代码:

- (UIImage*) processImage :(UIImage*) image
{
    UIImage *inputImage = [UIImage imageWithData:UIImageJPEGRepresentation(image, 1.0)];
    const float colorMasking[6]={100.0, 255.0, 0.0, 100.0, 100.0, 255.0};
    CGImageRef imageRef = CGImageCreateWithMaskingColors(inputImage.CGImage, colorMasking);
    UIImage* finalImage = [UIImage imageWithCGImage:imageRef];
    CGImageRelease(imageRef);
    return finalImage;
}
Run Code Online (Sandbox Code Playgroud)

以下是我发现的几个StackOverflow帖子,帮助我在iOS6中首先使用它: 透明度iOS iOS颜色在UIImage中透明

objective-c uiimage ios ios7

4
推荐指数
1
解决办法
3462
查看次数

标签 统计

ios ×1

ios7 ×1

objective-c ×1

uiimage ×1