FLAnimatedImage
FLAnimatedImage is a performant animated GIF engine for iOS:
FLAnimatedImage是一个播放gif图片的引擎:
It's a well-tested component that powers all GIFs in Flipboard. To understand its behavior it comes with an interactive demo:
这个已经经过了很多的测试,保证很稳定。你可以看看下面demo显示:
Who is this for? 用在什么地方?
FLAnimatedImage is a well encapsulated drop-in component. Simply replace your UIImageView
instances with instances of FLAnimatedImageView
to get animated GIF support. There is no central cache or state to manage.
FLAnimatedImage是一个继承与UIImageView的子类,你只需要简单的用FLAnimatedImage替换UIImageView即可支持GIF图片的显示。没有中心缓存或者是状态管理操作。
If using CocoaPods, the quickest way to try it out is to type this on the command line:
如果你使用CocoaPods,你可以用以下一句话来集成:
$ pod try FLAnimatedImage
To add it to your app, copy the two classes FLAnimatedImage.h/.m
and FLAnimatedImageView.h/.m
into your Xcode project or add via CocoaPods by adding this to your Podfile:
你也可以将FLAnimatedImage.h/.m
与 FLAnimatedImageView.h/.m拷贝到你的项目中即可。
pod 'FLAnimatedImage', '~> 1.0'
In your code, #import "FLAnimatedImage.h"
, create an image from an animated GIF, and setup the image view to display it:
在你的代码中,导入 #import "FLAnimatedImage.h",然后创建出GIF图片,加载出来显示即可:
FLAnimatedImage *image = [FLAnimatedImage animatedImageWithGIFData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://raphaelschaad.com/static/nyan.gif"]]]; FLAnimatedImageView *imageView = [[FLAnimatedImageView alloc] init]; imageView.animatedImage = image; imageView.frame = CGRectMake(0.0, 0.0, 100.0, 100.0); [self.view addSubview:imageView];
It's flexible to integrate in your custom image loading stack and backwards compatible to iOS 6.
兼容性很好,即时是iOS6也能跑的很顺畅。
It uses ARC and the Apple frameworks QuartzCore
, ImageIO
, MobileCoreServices
, andCoreGraphics
.
使用ARC,以及QuartzCore,ImageIO,MobileCoreServices,andCoreGraphics框架
It has fine-grained logging. By default, it uses NSLog. However, if your project usesCocoaLumberjack, it automatically can detect that and use CocoaLumberjack to send logs to the configured output.
Since FLAnimatedImage is licensed under MIT, it's compatible with the terms of using it for any app on the App Store.
FLAnimatedImage
should become a UIImage
subclassThis has successfully shipped to many people as is, but please do come with your questions, issues and pull requests!
Feel free to reach out to @RaphaelSchaad for further help.
Select apps using FLAnimatedImage
Using FLAnimatedImage in your app? Let me know!