0

这是经典动画,但我需要知道它何时真正完成。谢谢

UIImageView* campFireView = [[UIImageView alloc] initWithFrame:self.view.frame];
campFireView.frame = CGRectMake(255.0f,0.0f,512.0f,384.0f);

campFireView.animationImages = [NSArray arrayWithObjects:
  [UIImage imageNamed:@"wish_launch_up_low_00000.png"],
  [UIImage imageNamed:@"wish_launch_up_low_00001.png"],
  [UIImage imageNamed:@"wish_launch_up_low_00002.png"],
  [UIImage imageNamed:@"wish_launch_up_low_00003.png"],
  [UIImage imageNamed:@"wish_launch_up_low_00004.png"],
  [UIImage imageNamed:@"wish_launch_up_low_00005.png"],
  ,nil];


  campFireView.animationDuration = 0;
  campFireView.animationRepeatCount = 1;

  [campFireView startAnimating];

  [self.view addSubview:campFireView];
4

1 回答 1

1

检测 UIImageView 动画很痛苦.. 但如果你不介意混乱,你可以做这样的事情..

UIImageView* campFireView = [[UIImageView alloc] initWithFrame:self.view.frame];
campFireView.frame = CGRectMake(255.0f,0.0f,512.0f,384.0f);

campFireView.animationImages = [NSArray arrayWithObjects:
  [UIImage imageNamed:@"wish_launch_up_low_00000.png"],
  [UIImage imageNamed:@"wish_launch_up_low_00001.png"],
  [UIImage imageNamed:@"wish_launch_up_low_00002.png"],
  [UIImage imageNamed:@"wish_launch_up_low_00003.png"],
  [UIImage imageNamed:@"wish_launch_up_low_00004.png"],
  [UIImage imageNamed:@"wish_launch_up_low_00005.png"],
  ,nil];


  campFireView.animationDuration = 4;  // <--- I changed the duration.. 
  campFireView.animationRepeatCount = 1;

  [campFireView startAnimating];

  [self.view addSubview:campFireView];

...

  // detect it with timer
  [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];

-(void)OnTimer {
    if ( [campFireView isAnimating] )
    {
        // still animating
    }
    else
    {
        // Animating done
    }

}

这只是一个示例,但如果您的动画持续时间小于计时器,您可以使用计时器对其进行检查以验证 isAnimating ...

但是,有很多选项可以为其他 UIImageView 设置动画...

于 2013-04-18T23:43:34.053 回答