This is the ObjectiveC method that generates the GIF image:
@implementation NSArray (GIFImage)
- (NSString*)GIFImageWithImageDuration:(CGFloat)GIFImageDuration
{
NSArray *images = self;
NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"animated.gif"];
CGImageDestinationRef destination = CGImageDestinationCreateWithURL((CFURLRef)[NSURL fileURLWithPath:path],
kUTTypeGIF,
images.count,
NULL);
NSDictionary *frameProperties = [NSDictionary dictionaryWithObject:[NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:GIFImageDuration]
forKey:(NSString *)kCGImagePropertyGIFDelayTime]
forKey:(NSString *)kCGImagePropertyGIFDictionary];
NSDictionary *gifProperties = [NSDictionary dictionaryWithObject:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:0] forKey:(NSString *)kCGImagePropertyGIFLoopCount]
forKey:(NSString *)kCGImagePropertyGIFDictionary];
for ( NSInteger index = 0; index < images.count; index++ )
{
UIImage *image = (UIImage *)[images objectAtIndex:index];
CGImageDestinationAddImage(destination, image.CGImage, (CFDictionaryRef)frameProperties);
}
CGImageDestinationSetProperties(destination, (CFDictionaryRef)gifProperties);
CGImageDestinationFinalize(destination);
CFRelease(destination);
NSLog(@"animated GIF file created at %@", path);
return path;
}
@end
Running this method on iOS9 works great, GIF generates loops forever in browsers:

The same method is not executed on iOS10, GIF is no longer generated forever in browsers, it is played only once:

Also, inspired by this answer: https : //stackoverflow.com/a/165235/... , I made a hexadecimal comparison of the two GIFs generated in both iOS9 and iOS10, it seems that the segment (Netscape App) is missing from the GIF10 created by iOS10. this may be the reason that it does not work, but I cannot be sure.
, GIF- ( ObjectiveC), ?
