1.下载sdwebimage库:https://github.com/rs/SDWebImage
2.解压把下面的文件导入到工程里面
3.在需要用到的地方导入文件头#import “SDWebImage/UIImageView+WebCache.h”
这时如果你事先没有配置路径,那么则会报错找不到该文件,所以要进行配置
4,配置好之后则可以使用
UIImageView *imageview = [[UIImageView alloc]init];
imageview.frame = CGRectMake(100, 100, 100, 200);
[imageview sd_setImageWithURL:[NSURL URLWithString:@”http://g.hiphotos.baidu.com/image/pic/item/6c224f4a20a446230761b9b79c22720e0df3d7bf.jpg“]];
[self.view addSubview:imageview];
相关文章: