gpt4 book ai didi

ios - 如何为 uiimageview 设置动画并停止剩余进程

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

我正在做一个应用程序。因为我正在为 uiimageview 做动画来显示不同的图像,如下所示

    UIImageView * fearthersanimate = nil;
[fearthersanimate setCenter:sender.center];

fearthersanimate = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 120,200)];
[fearthersanimate setCenter:CGPointMake(sender.center.x, sender.center.y)];
fearthersanimate .animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"water_can_1.png"],
[UIImage imageNamed:@"water_can_2.png"],[UIImage imageNamed:@"water_can_3.png"],
[UIImage imageNamed:@"water_can_4.png"],[UIImage imageNamed:@"water_can_5.png"],
[UIImage imageNamed:@"water_can_6.png"],[UIImage imageNamed:@"water_can_7.png"],
[UIImage imageNamed:@"water_can_8.png"],
nil];
fearthersanimate.animationDuration = 1.0f;
fearthersanimate.animationRepeatCount = 1;
[self.view addSubview: fearthersanimate];
[fearthersanimate startAnimating];

但是剩余的操作在这个动画结束之前开始。但是我需要先做这个动画,直到我需要停止剩余的过程。

最佳答案

您可以在其他方法中调用其余操作,并在为图像设置动画时间的相同延迟后调用它。以下是您可以在一段时间间隔后调用其他方法的代码行

 [self performSelector:@selector(restOfOperations) withObject:nil afterDelay:1.0];  

//restOfOperations方法定义/实现

  -(void)restOfOperations
{
//your code you want to perform after image animation
}

关于ios - 如何为 uiimageview 设置动画并停止剩余进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21671988/

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