连续动画 - Watchkit [英] Consecutive Animations - Watchkit
问题描述
我希望为 Apple Watch 应用提供各种动画.我正在使用一系列图像,动画方法是 startAnimatingWithImagesInRange().每当我有连续的动画指令时,只会执行代码中的最后一个.代码如下:
I'm looking to have a variety of animations for an apple watch app. I'm using a series of images and the method of animation is startAnimatingWithImagesInRange(). Any time I have consecutive animation instructions, only the last one in the code executes. Code looks like:
myImage.setImageNamed("testImage")
myImage.startAnimatingWithImagesInRange(NSRange(location: 0, length: 90), duration: 3, repeatCount: 1)
myImage.startAnimatingWithImagesInRange(NSRange(location: 90, length: 180), duration: 3, repeatCount: 1)
在上面的代码中,只会播放第二个动画.我什至尝试将它们放在单独的函数中,所以我会单独调用每个函数,但它仍然只会播放我代码中的最后一个动画.我对此很陌生,所以我确信有更好的方法,但经过数小时的研究,我一直无法想出解决方案或在网上找到解决方案.
In the above code, only the second animation would play. I even tried putting them in separate functions, so I would be calling each function individually, but it still will only play the last animation in my code. I'm fairly new to this so I'm sure there is a better way but after hours and hours of research I haven't been able to come up with a solution or find one online.
推荐答案
手表不会为你排队动画,所以使用一个延迟等于第一个动画持续时间的 NSTimer 并在第二个动画结束后开始定时器触发.
The watch won't queue up animations for you, so use an NSTimer with a delay equal to the duration of the first animation and start the second animation once the timer fires.
这篇关于连续动画 - Watchkit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!