您的位置:首页 > 移动开发 > IOS开发

iOS GIF合成有透明通道图片重叠问题

2017-11-14 00:18 861 查看
iOS GIF合成有透明通道图片重叠问题

项目中需要用到合成gif, 如果图片含有透明通道, 则会出现重叠现象, 设置

kCGImagePropertyGIFHasGlobalColorMap

为true即可解决

下面是设置的代码, 

            NSMutableDictionary *gifProperty = [NSMutableDictionary
dictionary];
            [gifProperty setObject:[NSNumber
numberWithFloat:frame.frame_delay]
forKey:(__bridge
id)kCGImagePropertyGIFDelayTime];
            
            float sysVersion = [[[UIDevice
currentDevice] systemVersion]
floatValue];
            if (sysVersion >=
10.0) {
                // ios 10以下支持有问题 kCGImagePropertyGIFHasGlobalColorMap
                [gifProperty setObject:@(true)
forKey:(__bridge
id)kCGImagePropertyGIFHasGlobalColorMap];
            }
            NSDictionary *frameProperties =
@{ (__bridge id)kCGImagePropertyGIFDictionary: gifProperty
};
            CGImageRef ref = [frame
getImageRef];
            CGImageDestinationAddImage(destination, ref, (CFDictionaryRef)frameProperties);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: