guodegangGDG 2013-04-19 02:57 采纳率: 0%
浏览 2906

怎么判断png动画结束了

就是一个普通动画,需要判断出动画是否结束:

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];

非常感谢您的帮助。

  • 写回答

1条回答 默认 最新

  • love_loveec 2013-04-19 03:27
    关注

    想要判断动画结束可能会引起很多其他麻烦。不过你可以试试这样的方法:

    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
        }
    }
    

    只是举个例子,如果你的动画周期比timer短,可以用timer里进行isAnimating检测

    评论

报告相同问题?

悬赏问题

  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入