如何在iphone上显示图像动画 [英] How do i show image animation on iphone

查看:166
本文介绍了如何在iphone上显示图像动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个动画gif(比如这个),当我在我的iPhone应用程序的图像视图中显示它只显示第一帧。此行为与Apple文档一致。
我想知道在iPhone上实现这一目标的最佳方法是什么?

I have a animated gif ( like this one ) , when I show in an image view on my iphone app it just shows the first frame . This behavior is consistent with the apple documentation . I was wondering what is the best way to achieve this on the iphone ?

推荐答案

这是我的一些代码我参加了一个当前的项目。我有一个循环将图像standy2放到standby7.png到一个数组。我使用的是imageWithContentsOfFile,因为它在内存使用方面看起来好一些。

Here's some code that I've got in a current project. I've got a loop to put images standy2 through to standby7.png into an array. Am using imageWithContentsOfFile since that seems to be a little better on memory usage.

standbyAnimationImages = [[NSMutableArray alloc] init];
for (NSUInteger i=2; i<=7; i++) {
    filename = [NSString stringWithFormat:@"standby%d", i];
    [standbyAnimationImages addObject:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:filename ofType:@"png"]]];
}

imageViewAnimation.animationImages = standbyAnimationImages;
imageViewAnimation.animationDuration = 2;
imageViewAnimation.animationRepeatCount = 0;
[imageViewAnimation startAnimating];

希望这可以帮到你。

这篇关于如何在iphone上显示图像动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆