gpt4 book ai didi

objective-c - 检查动画何时停止

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:32:33 24 4
gpt4 key购买 nike

我正在制作一个简单的 UIImageView 动画。基本上我得到了一堆 0-9 的图像编号,我正在使用这段代码为它们制作动画。

myAnimation.animationImages = myArray;
myAnimation.animationDuration = 0.7;
myAnimation.animationRepeatCount = 12;
[myAnimation startAnimating];

这里 myArray 是 uiimages 的数组,即 0.png、1.png 等。

一切都很好,它的动画也很好。我需要知道的是我什么时候知道动画何时停止?我可以使用 NSTimer 但为此我需要一个秒表来检查动画何时开始和停止。有没有更好的方法,这意味着我可以找出 UIImageView 何时停止动画?

我查看了这个线程作为引用。

UIImageView startAnimating: How do you get it to stop on the last image in the series?

最佳答案

使用 animationDidStopSelector。这将在动画完成时触发:

[UIView setAnimationDidStopSelector:@selector(someMethod:finished:context:)];

然后实现选择器:

- (void)someMethod:(NSString*)animationID finished:(NSNumber*)finished context:(void*)context {

}

关于objective-c - 检查动画何时停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10434849/

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