gpt4 book ai didi

iphone - iOS 中如何判断一个简单的 png 动画何时完成?

转载 作者:行者123 更新时间:2023-11-29 03:59:14 25 4
gpt4 key购买 nike

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

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

最佳答案

检测 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 提供动画效果...

关于iphone - iOS 中如何判断一个简单的 png 动画何时完成?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16094625/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com