连续animation – Watchkit

我正在寻找一个苹果手表应用程序的各种animation。 我正在使用一系列图像,animation的方法是startAnimatingWithImagesInRange()。 任何时候我有连续的animation指令,只有代码中的最后一个执行。 代码如下所示:

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) 

在上面的代码中,只有第二个animation会播放。 我甚至尝试把它们放在单独的函数中,所以我将单独调用每个函数,但它仍然只会播放我的代码中的最后一个animation。 我对此相当陌生,所以我确信有一个更好的方法,但经过几个小时和几个小时的研究,我还没有能够提出一个解决scheme或find一个在线。

手表不会为您排队animation,所以请使用延迟时间与第一个animation的持续时间相同的NSTimer,并在计时器启动后启动第二个animation。

这很容易1 + 1 🙂

这是你想要的:

 myImage.setImageNamed("testImage") let duration = 3 let repeatCount = 1 Timeline.with(identifier: "MyQueuedAnimation", delay: 0.0, duration: duration * repeatCount, execution: { myImage.startAnimatingWithImagesInRange(NSRange(location: 0, length: 90), duration: duration, repeatCount: repeatCount) }, completion: { myImage.startAnimatingWithImagesInRange(NSRange(location: 90, length: 180), duration: duration, repeatCount: 1) }).start 

TimelineKit – 随时给我一些反馈,为我的小框架。 🙂