ios - 连续动画 - Watchkit

标签 ios swift watchkit

我希望为 Apple Watch 应用程序提供各种动画。我正在使用一系列图像,动画方法是 startAnimatingWithImagesInRange()。每当我有连续的动画指令时,代码中只会执行最后一个指令。代码如下:

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)

在上面的代码中,只有第二个动画会播放。我什至尝试将它们放在不同的函数中,所以我会单独调用每个函数,但它仍然只会播放我代码中的最后一个动画。我对此还很陌生,所以我确信有更好的方法,但经过数小时的研究后,我无法提出解决方案或在网上找到解决方案。

最佳答案

这就像 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 - 请随时给我一些关于我的小框架的反馈。 :)

关于ios - 连续动画 - Watchkit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29200549/

相关文章:

ios - 将背景图像添加到 SpriteKit 项目

ios - 为什么我在 iphone 应用程序发布之前获得 admob 点击

ios - UIActivityViewController 显示空白选项且无法交互

ios - 在 WatchOS 端创建自定义 Long-Nook 通知

ios - WatchKit:在通知短外观和长外观中更改应用程序名称?

objective-c - NSURLErrorDomain : Cannot decode raw data

iOS 图像 startAnimating 不是动画(大多数时候)

删除条目后 UITableView 卡住

ios - 如何从 UISegmentedControl 创建 IBAction?

WatchKit:在 watch 和 iPhone 应用程序之间同步计时器?