我有几个UIButtons,当我在屏幕中间按下其他不相关的东西时,我想要触发短5-10帧动画。我可以在IB中放置一个UIImageView并以编程方式更新它吗?它不需要过于复杂,我甚至不介意它是否被硬编码,因为它是一个如此小的项目。简单的动画[iPhone]
谢谢。
我有几个UIButtons,当我在屏幕中间按下其他不相关的东西时,我想要触发短5-10帧动画。我可以在IB中放置一个UIImageView并以编程方式更新它吗?它不需要过于复杂,我甚至不介意它是否被硬编码,因为它是一个如此小的项目。简单的动画[iPhone]
谢谢。
这里是你做的,只需几帧的动画是最简单的方法的例子:
声明一个IBOutlet UIImageView *timerAnimation
并将其链接到您的IB的UIImageView。为您的资源添加一些图片,例如您在下面看到的需要。然后将图像加载到一个数组 - 看到代码:
timerAnimation.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"timer00.png"],
[UIImage imageNamed:@"timer01.png"],
[UIImage imageNamed:@"timer02.png"],
[UIImage imageNamed:@"timer03.png"],
[UIImage imageNamed:@"timer04.png"],
[UIImage imageNamed:@"timer05.png"],
[UIImage imageNamed:@"timer06.png"],
[UIImage imageNamed:@"timer07.png"],
[UIImage imageNamed:@"timer08.png"],
[UIImage imageNamed:@"timer09.png"],
[UIImage imageNamed:@"timer10.png"],
[UIImage imageNamed:@"timer11.png"],
[UIImage imageNamed:@"timer12.png"],
[UIImage imageNamed:@"timer13.png"],
[UIImage imageNamed:@"timer14.png"],
[UIImage imageNamed:@"timer15.png"],
[UIImage imageNamed:@"timer16.png"],
[UIImage imageNamed:@"timer17.png"],
[UIImage imageNamed:@"timer18.png"],
[UIImage imageNamed:@"timer19.png"],
[UIImage imageNamed:@"timer20.png"],
[UIImage imageNamed:@"timer21.png"],
[UIImage imageNamed:@"timer22.png"],
[UIImage imageNamed:@"timer23.png"],
[UIImage imageNamed:@"timer24.png"],
[UIImage imageNamed:@"timer25.png"],
[UIImage imageNamed:@"timer26.png"],
[UIImage imageNamed:@"timer27.png"],
[UIImage imageNamed:@"timer28.png"],
[UIImage imageNamed:@"timer29.png"],
[UIImage imageNamed:@"timer30.png"],
[UIImage imageNamed:@"timer31.png"],
[UIImage imageNamed:@"timer32.png"],
[UIImage imageNamed:@"timer33.png"],
[UIImage imageNamed:@"timer34.png"],
[UIImage imageNamed:@"timer35.png"],
// [UIImage imageNamed:@"timer36.png"], save last picture for "times up"
nil];
timerAnimation.animationDuration = 5.0;
timerAnimation.animationRepeatCount = 1;
[timerAnimation startAnimating];
,直到调用[timerAnimation stopAnimating];
YES YES YES YES这将运行你的动画!这绝对正是我所需要的。不是太复杂,只是简单到易于实现。 – nullArray 2009-10-28 16:37:07