Swift中每个动画迭代后的延迟 [英] Delay after each animation iteration in Swift
本文介绍了Swift中每个动画迭代后的延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个核心动画,其 .repeatCount
设置为 Float.infinity
。在动画的每次迭代之后,即每次重复之后,我希望延迟3秒。我该如何实现?谢谢!
I have a Core Animation whose .repeatCount
is set to Float.infinity
. After each iteration of the Animation, ie. after each repetition, I want to have a delay of 3 seconds. How can I achieve this? Thanks!
推荐答案
您可以使用函数
进行以下操作
You can use a function
like the following to do what you need.
func animateInfinitelyWithDelay(delay: TimeInterval, duration: TimeInterval) {
UIView.animate(
withDuration: duration,
delay: delay,
options: UIView.AnimationOptions.curveEaseIn,
animations: { () -> Void in
// Your animation Code
}) { (finished) -> Void in
if finished {
self.animateInfinitelyWithDelay(delay: delay, duration: duration)
}
}
}
这篇关于Swift中每个动画迭代后的延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文