码迷,mamicode.com
首页 > Web开发 > 详细

webp图片加载

时间:2020-04-15 11:05:18      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:target   flag   targe   color   elf   tin   The   静态库   int   

1.下载该静态库并导入

<https://github.com/YouZhiZheShiJingCheng/YZwebp>;

2.配置工程

TARGETS->Build Settings->Other Linker Flags 添加一个 -ObjC

3.开始应用

    UIImageView* webp=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
    //后缀为小写的时候可以省略
    webp.image=[UIImage imageWithWebP:@"a"];
    webp.backgroundColor=[UIColor redColor];
    webp.center=CGPointMake(self.view.center.x, self.view.center.y*0.5);
    [self.view addSubview:webp];

    UIImageView* webp1=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
    webp1.image=[UIImage imageWithWebP:@"a.webp"];
    webp1.backgroundColor=[UIColor greenColor];
    webp1.center=self.view.center;
    [self.view addSubview:webp1];

    //名字大小写不对识别不了
    UIImageView* webp2=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
    webp2.image=[UIImage imageWithWebP:@"a.WEBP"];
    webp2.center=CGPointMake(self.view.center.x, self.view.center.y*1.5);
    webp2.backgroundColor=[UIColor blueColor];
    [self.view addSubview:webp2];

Demo地址:

<https://github.com/YouZhiZheShiJingCheng/WebpDemo>;

webp图片加载

标签:target   flag   targe   color   elf   tin   The   静态库   int   

原文地址:https://blog.51cto.com/2254359459/2487341

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!