sdwebimage 加载webp图片

sdwebimage加载 webp / git 

配置宏

 

- (void)setUpCusPhoto
{
    _scrollView = [UIScrollView new];
    _scrollView.frame = self.view.bounds;
    [self.view addSubview:_scrollView];
    
    //webp
    UIImageView *view = [[UIImageView alloc] init];
    view.frame = CGRectMake(10, 100, 320, 200);
    NSString *url = @"http://www.ioncannon.net/wp-content/uploads/2011/06/test2.webp";
    [view sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"pia"]];
    [_scrollView addSubview:view];
    
//   view.image =  [UIImage sd_imageWithWebPData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url]]];

    
    //jpg
    UIImageView *view1 = [[UIImageView alloc] init];
    view1.frame = CGRectMake(10, 100+200+10, 320, 200);
    NSString *url1 = @"http://testadmin.jrtoo.com:8081/Uploads/2017/06/20/594884bf71f2a.jpeg";
    [view1 sd_setImageWithURL:[NSURL URLWithString:url1] placeholderImage:[UIImage imageNamed:@"pia"]];
    [_scrollView addSubview:view1];
    
    //gif
    UIImageView *view3 = [[UIImageView alloc] init];
    view3.frame = CGRectMake(10, 100+200+200+10+10, 320, 200);
    NSString *url3 = @"https://upload.wikimedia.org/wikipedia/commons/2/2c/Rotating_earth_%28large%29.gif";
    [view3 sd_setImageWithURL:[NSURL URLWithString:url3] placeholderImage:[UIImage imageNamed:@"pia"]];
    [_scrollView addSubview:view3];
    
    _scrollView.contentSize = CGSizeMake(self.view.width, view3.bottom + 20);
}

yyimage 支持webp gif,sdwebimage不支持

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithWhite:0.863 alpha:1.000];
    //http://www.ioncannon.net/wp-content/uploads/2011/06/test2.webp
    
    YYImage *image = [YYImage imageNamed:@"nyancat@2x.webp"];
    YYAnimatedImageView *imageView = [[YYAnimatedImageView alloc] initWithImage:image];
    imageView.frame = CGRectMake(10, 100, 320, 200);
    [self.view addSubview:imageView];

//    [self setUpUI];

//    [self setUpCusPhoto];
    
    
}

备注:

   1 :sdwebimage 本身支持网路请求webp格式图片,如图 代码

 [view sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"pia"]];
直接请求webp图片,但是webp格式的gif图片还没支持!

2:YYImage 不仅支持webp格式的图片,而且对webp格式的gif图 同样支持!


 

http://download.csdn.net/detail/ly122145736/9882671  //demo加载地址

 

posted @ 2017-06-28 10:59  看谷秀  阅读(2623)  评论(0编辑  收藏  举报