简单动画[iPhone] 我有几个UIButtons,我想在屏幕中间按下5~10帧动画,以及其他无关的东西。我可以在IB中删除一个UIImageView并以编程方式进行更新吗?它不需要太复杂,我甚至不介意它是否是硬编码的,因为它是一个如此小的项目

简单动画[iPhone] 我有几个UIButtons,我想在屏幕中间按下5~10帧动画,以及其他无关的东西。我可以在IB中删除一个UIImageView并以编程方式进行更新吗?它不需要太复杂,我甚至不介意它是否是硬编码的,因为它是一个如此小的项目,iphone,animation,uiimageview,Iphone,Animation,Uiimageview,谢谢。是的。为UIImageView创建一个IBOutlet,您可以从代码中更新它。例如,使用其属性设置应显示的UIImage。或者,您可以将图像添加到应用程序的资源中,并将其与Interface Builder中的UIImageView关联。使用.png文件,因为iPhone已经为它们进行了优化。 由于UIImageView是UIView,因此可以使用所有常用的核心动画。以下是一个只需几帧即可制作动画的最简单方法示例: 声明一个IBOutlet UIImageView*timerAnimati

谢谢。

是的。为UIImageView创建一个IBOutlet,您可以从代码中更新它。例如,使用其属性设置应显示的UIImage。或者,您可以将图像添加到应用程序的资源中,并将其与Interface Builder中的UIImageView关联。使用.png文件,因为iPhone已经为它们进行了优化。

由于UIImageView是UIView,因此可以使用所有常用的核心动画。

以下是一个只需几帧即可制作动画的最简单方法示例:

声明一个
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 Stop Animating]

是的!这正是我所需要的。不太复杂,只是简单到易于实现。