iOS開發(fā)動態(tài)圖—非UIWebView顯示本地動態(tài)圖

在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 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來展示動態(tài)圖,如果可以使用4.0以上版本的SDWebImage則可以使用此方法?;蛘咧苯觩od導(dǎo)入FLAnimatedImage來顯示動態(tài)圖。


最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容