在iOS中使用本地動態(tài)圖,UIimageView無法直接顯示,使用UIWebView顯示,在iOS8下會出現(xiàn)圖片很小的問題。遂換為使用SDWebImage,我的使用方法如下:
SDWebImage(3.8.2)版本
1、添加SDWebImage到工程中
1.在工程的Podfile文件中添加:pod 'SDWebImage'
2.啟用終端,cd到工程目錄下,如:cd /Users/admin/Documents/Project/TuanG
3.在終端中更新pod:pod install
2、在需要展示動態(tài)圖片的地方添加UIImageVIew,并做如下使用
UIImage *gifImage = [UIImage sd_animatedGIFNamed:@"localGifImageNameString"];
gifImageView.image = gifImage;
加入以上代碼即可使用顯示動態(tài)圖。
SDWebImage(4.0)版本
SDWebImage中使用動態(tài)圖的描述如下:
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
FLAnimatedImageViewinstead ofUIImageView.- 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, use
NSImageViewwithanimatesset 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來展示動態(tài)圖,如果可以使用4.0以上版本的SDWebImage則可以使用此方法?;蛘咧苯觩od導(dǎo)入FLAnimatedImage來顯示動態(tài)圖。