[翻譯] FLAnimatedImage


FLAnimatedImage

FLAnimatedImage is a performant animated GIF engine for iOS:

FLAnimatedImage是一個播放gif圖片的引擎:

  • Plays multiple GIFs simultaneously with a playback speed comparable to desktop browsers 可以異步播放多個gif圖片,不會降低速度,與電腦上面播放的效果一致.
  • Honors variable frame delays 支持幀率的不同
  • Behaves gracefully under memory pressure 內存占用率小
  • Eliminates delays or blocking during the first playback loop 重復播放時,不會有延時阻塞感
  • Interprets the frame delays of fast GIFs the same way modern browsers do 

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? 用在什么地方?

  • Apps that don't support animated GIFs yet App還不支持GIF顯示的
  • Apps that already support animated GIFs but want a higher performance solution App已經使用了GIF圖片,但是效果不好的
  • People who want to tinker with the code (the corresponding blog post is a great place to start; also see the To Do section below) 那些想要改進這份代碼的人

 

Installation & Usage

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/.minto 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 QuartzCoreImageIOMobileCoreServices, 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.

 

To Do

  • Support other animated image formats such as APNG or WebP
  • Integration into network libraries and image caches
  • Investigate whether FLAnimatedImage should become a UIImage subclass
  • Smarter buffering
  • Bring demo app to iOS 6 and iPhone

This 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!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM