Complete Animated GIF Support for iOS, with Functions, NSJSONSerialization-style Class, and (Optional) UIImage Swizzling
Objective-C
1,072
48 commits
updated Jul 6, 2019
This library is no longer maintained. In iOS 13+ and macOS 10.15+, use
CGAnimateImageAtURLWithBlockinstead.
AnimatedGIFImageSerialization decodes an UIImage from
Animated GIFs,
following the API conventions of Foundation's NSJSONSerialization class.
By default, UIImage initializers can't decode animated images from GIF files.
This library uses swizzling to provide this functionality for you.
To opt out of this behavior,
set ANIMATED_GIF_NO_UIIMAGE_INITIALIZER_SWIZZLING in your build environment.
If you're using CocoaPods,
you can add this build setting to your Podfile:
post_install do |r|
r.pods_project.targets.each do |target|
if target.name == 'AnimatedGIFImageSerialization' then
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||=
['$(inherited)', 'ANIMATED_GIF_NO_UIIMAGE_INITIALIZER_SWIZZLING=1']
end
end
end
end
UIImageView *imageView = ...;
imageView.image = [UIImage imageNamed:@"animated.gif"];

UIImage *image = ...;
NSData *data = [AnimatedGIFImageSerialization animatedGIFDataWithImage:image
duration:1.0
loopCount:1
error:nil];
Mattt (@mattt)
AnimatedGIFImageSerialization is available under the MIT license. See the LICENSE file for more info.
61 followers · starred Apr 2014
51 followers · starred May 2014
13 followers · starred Mar 2014
29 followers · starred Mar 2014
Complete Animated GIF Support for iOS, with Functions, NSJSONSerialization-style Class, and (Optional) UIImage Swizzling
Objective-C
1,072
48 commits
updated Jul 6, 2019
This library is no longer maintained. In iOS 13+ and macOS 10.15+, use
CGAnimateImageAtURLWithBlockinstead.
AnimatedGIFImageSerialization decodes an UIImage from
Animated GIFs,
following the API conventions of Foundation's NSJSONSerialization class.
By default, UIImage initializers can't decode animated images from GIF files.
This library uses swizzling to provide this functionality for you.
To opt out of this behavior,
set ANIMATED_GIF_NO_UIIMAGE_INITIALIZER_SWIZZLING in your build environment.
If you're using CocoaPods,
you can add this build setting to your Podfile:
post_install do |r|
r.pods_project.targets.each do |target|
if target.name == 'AnimatedGIFImageSerialization' then
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||=
['$(inherited)', 'ANIMATED_GIF_NO_UIIMAGE_INITIALIZER_SWIZZLING=1']
end
end
end
end
UIImageView *imageView = ...;
imageView.image = [UIImage imageNamed:@"animated.gif"];

UIImage *image = ...;
NSData *data = [AnimatedGIFImageSerialization animatedGIFDataWithImage:image
duration:1.0
loopCount:1
error:nil];
Mattt (@mattt)
AnimatedGIFImageSerialization is available under the MIT license. See the LICENSE file for more info.
61 followers · starred Apr 2014
51 followers · starred May 2014
13 followers · starred Mar 2014
29 followers · starred Mar 2014