在iOS中使用本地動(dòng)態(tài)圖茅撞,UIimageView無法直接顯示巨朦,使用UIWebView顯示米丘,在iOS8下會(huì)出現(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稍算、在需要展示動(dòng)態(tài)圖片的地方添加UIImageVIew,并做如下使用
UIImage *gifImage = [UIImage sd_animatedGIFNamed:@"localGifImageNameString"];
gifImageView.image = gifImage;
加入以上代碼即可使用顯示動(dòng)態(tài)圖钾埂。
SDWebImage(4.0)版本
SDWebImage中使用動(dòng)態(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
FLAnimatedImageView
instead 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
NSImageView
withanimates
set toYES
to show the entire animated images andNO
to 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來展示動(dòng)態(tài)圖科平,如果可以使用4.0以上版本的SDWebImage則可以使用此方法」试矗或者直接pod導(dǎo)入FLAnimatedImage來顯示動(dòng)態(tài)圖汞贸。