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

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);


你可能感兴趣的:(ios)