iPhone 的 Animated GIF 库。基于 Martin van Spanje 的原始工作。
这个库旨在使在 iOS 上使用 Animated GIF 变得更容易。它包括 Martin van Spanje 的原始代码,以及开源社区的大量改进。现在的代码遵循 GIF89a 标准,并支持透明度。暂不支持 LZW 压缩(欢迎 pull requests)。
/* First example, a local file */
NSURL *localUrl = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"apple_logo_animated" ofType:@"gif"]];
UIImageView *localAnimation = [AnimatedGif getAnimationForGifAtUrl: localUrl];
// For local files (that are loaded immediatly) you can request the size
localAnimation.frame = CGRectMake(10.0f, 194.0f, localAnimation.image.size.width, localAnimation.image.size.height);
/* Second example, through HTTP */
NSURL *remoteUrl = [NSURL URLWithString:@"http://i.imgur.com/vnwRc8V.gif"];
UIImageView *remoteAnimation = [AnimatedGif getAnimationForGifAtUrl: remoteUrl];
// For remote files you will need to specify the size in advance, as iOS_AnimatedGif
// does not support callbacks yet...
remoteAnimation.frame = CGRectMake(170.0f, 194.0f, 140.0f, 180.0f);
// Add both examples to the view.
[self.view addSubview:localAnimation];
[self.view addSubview:remoteAnimation];
由于 CocoaPods 越来越受欢迎,这个库也已经被添加为 pod。您可以在 Podfile 中包含以下内容
pod iOS_AnimatedGif
MIT 许可证
特此许可,免费向任何获得此软件和相关文档副本(“软件”)的个人提供,无限制地使用软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本,并允许向软件提供副本的个人执行上述操作,前提是
上述版权声明和本许可声明应包含在软件的所有副本或实质部分中。
软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、针对特定目的的适用性和非侵权性保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任负责,无论该责任源自合同、侵权或其他方式,与软件或软件的使用或任何其他方式有关。
2014-06-11: 解决了大量编译警告 + 通过 github.com/eimantas 优化了 ARC 和现代化 2010-03-16: 添加了对静态类使用的排队机制 2010-01-24: 重构整个模块,添加静态方法,更好的内存管理和 URL 异步加载 2009-10-08: 添加 dealloc 方法,并移除了泄漏,由 Pedro Silva 实现 2009-08-10: 修复了对数组的双重释放,由 Christian Garbers 实现 2009-06-05: 初版