iOS 的 Gif 渲染引擎 FLAnimatedImage-b

公司的项目有个首页加载一张2M左右的git图,刚做的时候是使用的SDWebImage里面的方法:

+ (UIImage *)sd_animatedGIFNamed:(NSString *)name;
+ (UIImage *)sd_animatedGIFWithData:(NSData *)data;

使用之后发现这个方法会使内存迅速上增300M,在网上找了一些方法:

//在didReceiveMemoryWarning方法中释放SDImage的缓存即可!
- (void)didReceiveMemoryWarning {
        [superdidReceiveMemoryWarning];
    // Dispose of     any resources that can be recreated.
        [[SDWebImageManagersharedManager]cancelAll];
        [[SDImageCachesharedImageCache]clearDisk];
}

但是使用之后发现效果并不明显,于是使用了这个FLAnimatedImage

FLAnimatedImage 是 iOS 的一个渲染 Gif 动画的引擎。

功能:

  • 可同时播放多个 Gif

     动画,速度媲美桌面浏览器

  • 可变帧延迟

  • 内存占用小

  • 可在第一次循环播放时消除或者阻止延迟

  • 动画的帧延迟解析性能媲美浏览器

示例代码:

 
 

FLAnimatedImage *image = [FLAnimatedImage animatedImageWithGIFData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"https://upload.wikimedia.org/wikipedia/commons/2/2c/Rotating_earth_%28large%29.gif"]]]; FLAnimatedImageView *imageView = [[FLAnimatedImageView alloc] init]; imageView.animatedImage = image; imageView.frame = CGRectMake(0.0, 0.0, 100.0, 100.0); [self.view addSubview:imageView];

效果图:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值