1,网络图片直接用SDWebImage基本可以全部解决:
包括普通图片和静态图片
[_imageView sd_setImageWithURL:[NSURL URLWithString:@"http://s1.dwstatic.com/group1/M00/A4/4E/45945d85fd5d2a976665f4390aa159c1.gif"]];
2,本地普通图片直接用UIImageView展示即可
3,本地动态图片的展示方法比较多,这里简单介绍几种:
//SDWebImage本地gif图片直接用原有方法设置即可
[_imageView sd_setImageWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"test.gif" ofType:nil]]];
/*webView方式一本地gif加载
//但是这种体验感觉很慢,不太好
NSString *html = @"<html><head><body>zhangzhang<img src=\"test.gif\" width = \"200\"><body></head></html>";
NSString *path = [[NSBundle mainBundle] resourcePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
[_webView loadHTMLString:html baseURL:baseURL];
*/
/*webView方式二本地gif加载
//但是这种体验感觉很慢,不太好
NSData *gif = [NSData dataWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"test" ofType:@"gif"]];
_webView.userInteractionEnabled = NO;
[_webView loadData:gif MIMEType:@"image/gif" textEncodingName:@"UTF-8" baseURL:nil];
//设置webview背景透明,能看到gif的透明层
_webView.backgroundColor = [UIColor blackColor];
_webView.opaque = NO;
*/