1.下图为 APNG 动图

备注 APNG格式 但是 其扩展名仍然是 png

2.APNG 介绍 以及 有关文章
https://www.zhangxinxu.com/wordpress/2014/09/apng-history-character-maker-editor/
https://www.cnblogs.com/diligenceday/p/4472035.html
https://www.zhihu.com/question/27201109
优缺点
1.无锯齿 色系丰富。(优点) APNG 图片 比 GIF 图片更加流畅,没有锯齿,色系更加丰富,
2.内存小。(优点) APNG 同一个动态图 也要比GIF 占用内存小
3.压缩 耗时(缺点) 由于相较于GIF,APNG 压缩后 失帧率很多
4.只有部分浏览器支持(缺点) GIF 几乎被 市场上所有的浏览器支持(参考 第一个链接简介)


3.OC中使用APNG图片 代码
1.引入
#import "UIImage+GIF.h"
导入 对应 (111.png)图片到 主束中
2.代码
NSString * path = [[NSBundle mainBundle] pathForResource:@"111" ofType:@"png"];
NSData * gifData = [NSData dataWithContentsOfFile:path];
UIImage * gifImage = [UIImage sd_animatedGIFWithData:gifData];
UIImageView * aa = [[UIImageView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)];
//aa.backgroundColor = [UIColor whiteColor];
aa.image = gifImage;
[self.view addSubview:aa];
网友评论