webp图片加载

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

posted @   会装系统的程序员  阅读(333)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· 展开说说关于C#中ORM框架的用法!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
点击右上角即可分享
微信分享提示