【发布时间】:2014-11-01 14:01:51
【问题描述】:
我正在尝试多次为视图的背景设置动画。例如(当然需要动态解)4秒,每一秒它都会从白色变为黑色。我们的期望: 第二:
- 白到黑到白
- 白到黑到白
- 白到黑到白
- 白到黑到白
我尝试使用 for 甚至延迟(调度延迟),它只会运行 1 次 而不是停下来。这是我尝试过的。
for var index = 0; index < 3; ++index {
UIView.animateWithDuration(0.33333, delay: 0.333333, options: UIViewAnimationOptions.CurveEaseIn, animations: { () -> Void in
println(elapsedTime)
self.view.backgroundColor = UIColor.blackColor()
}) { (completed : (Bool)) -> Void in
UIView.animateWithDuration(0.333333, animations: { () -> Void in
self.view.backgroundColor = UIColor.whiteColor()
})
}
}
关于如何运行这些命令的任何建议,等到它们完成后再运行它们?
【问题讨论】:
标签: swift task wait uiviewanimation