gpt4 book ai didi

Swift 3 - 延迟重复动画

转载 作者:搜寻专家 更新时间:2023-11-01 06:33:45 25 4
gpt4 key购买 nike

目前,此动画每 3 秒重复一次。我希望在重复此动画之间有 10 秒的等待时间。我怎样才能做到这一点?

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)


UIView.animate(withDuration: 7.5, delay: 20,
options: .repeat,
animations: {
self.imageAnimate.center.x += self.view.bounds.width * 2
},
completion: nil
)
}

最佳答案

使用定时器:

// note that I used 17.5 here because the animation itself takes 7.5 seconds
// so that will be 7.5 seconds of animating, 10 seconds of doing nothing
// and start animating again
Timer.scheduledTimer(withTimeInterval: 17.5, repeats: true) {
UIView.animate(withDuration: 7.5, animations: {
self.imageAnimate.center.x += self.view.bounds.width * 2
})
}

关于Swift 3 - 延迟重复动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44166557/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com