首页 > 代码库 > iOS加载Gif图片

iOS加载Gif图片

 

参考:

http://www.jianshu.com/p/f0530a75c7af


 https://github.com/Flipboard/FLAnimatedImage 

 

  

 

马蛋的一个加载的菊花不转了 

发现

   // NSString *path = [[NSBundle mainBundle] pathForResource:@"spin" ofType:@"gif"];
  //  NSData *data = http://www.mamicode.com/[NSData dataWithContentsOfFile:path];>// UIImage *image = [UIImage sd_animatedGIFWithData:data];

  //  cell.loadingImg.image=image;

这个不能用了  重要的是 :

sd的sd_animatedGIFWithData方法返回的image只包含第一帧。

 

找了新方法

使用FLAnimatedImageView。

<style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #d12f1b } span.s1 { color: #78492a } span.s2 { }</style>

#import <FLAnimatedImage/FLAnimatedImageView.h>


#import <FLAnimatedImage/FLAnimatedImage.h>



<style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #3e1e81 } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000 } p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #4f8187 } p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; min-height: 16.0px } span.s1 { color: #000000 } span.s2 { color: #703daa } span.s3 { } span.s4 { color: #d12f1b } span.s5 { color: #3e1e81 } span.s6 { color: #31595d }</style>

 NSString *path = [[NSBundle mainBundle] pathForResource:@"spin" ofType:@"gif"];

    NSData *data = http://www.mamicode.com/[NSData dataWithContentsOfFile:path];

    FLAnimatedImage *image = [FLAnimatedImage animatedImageWithGIFData:data];

   

   FLAnimatedImageView *imageView = [FLAnimatedImageView new];

   

    imageView.animatedImage = image;


 

<style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #008400 } span.s1 { }</style> <style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #3e1e81 } p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #4f8187 } p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #31595d } p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000; min-height: 16.0px } p.p5 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #000000 } span.s1 { color: #000000 } span.s2 { color: #703daa } span.s3 { } span.s4 { color: #d12f1b } span.s5 { color: #3e1e81 } span.s6 { color: #4f8187 }</style> <style>p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Menlo; color: #d12f1b } span.s1 { color: #78492a } span.s2 { }</style>

iOS加载Gif图片