iOS开发动态图—非UIWebView显示本地动态图

在iOS中使用本地动态图,UIimageView无法直接显示,使用UIWebView显示,在iOS8下会出现图片很小的问题。遂换为使用SDWebImage,我的使用方法如下:

SDWebImage(3.8.2)版本

1、添加SDWebImage到工程中

1.在工程的Podfile文件中添加:pod 'SDWebImage'
2.启用终端,cd到工程目录下,如:cd /Users/admin/Documents/Project/TuanG
3.在终端中更新pod:pod install

2、在需要展示动态图片的地方添加UIImageVIew,并做如下使用

UIImage *gifImage = [UIImage sd_animatedGIFNamed:@"localGifImageNameString"]; 
gifImageView.image = gifImage;

加入以上代码即可使用显示动态图。


SDWebImage(4.0)版本

SDWebImage中使用动态图的描述如下:

Animated Images (GIF) support

  • Starting with the 4.0 version, we rely on FLAnimatedImage to take care of our animated images.
  • If you use cocoapods, add pod 'SDWebImage/GIF' to your podfile.
  • To use it, simply make sure you use FLAnimatedImageView instead of UIImageView.
  • Note: there is a backwards compatible feature, so if you are still trying to load a GIF into a UIImageView, it will only show the 1st frame as a static image.
  • Important: FLAnimatedImage only works on the iOS platform. For OS X, useNSImageView with animatesset toYESto show the entire animated images andNOto only show the 1st frame. For all the other platforms (tvOS, watchOS) we will fallback to the backwards compatibility feature described above

此处说明自SDWebImage在4.0以后依赖FLAnimatedImage来展示动态图,如果可以使用4.0以上版本的SDWebImage则可以使用此方法。或者直接pod导入FLAnimatedImage来显示动态图。


你可能感兴趣的:(iOS开发动态图—非UIWebView显示本地动态图)