gpt4 book ai didi

iOS 在按下时禁用动画

转载 作者:行者123 更新时间:2023-11-29 11:49:23 25 4
gpt4 key购买 nike

当我按下后退按钮时,动画再次开始并且我松开屏幕上的按钮。

为了更好地理解,这里有一个 gif:

https://i.gyazo.com/9d2ec00152c614c94a2ab2c797e86e12.gif

eoverride func viewDidLoad() {
super.viewDidLoad()

std.center.x += view.bounds.width
prtl.center.x += view.bounds.width
.
.

}

override func viewWillAppear(_ animated: Bool)
{
UIView.animate(withDuration: 0.5, delay: 0.5, options: [], animations: {
self.std.center.x -= self.view.bounds.width
}, completion: nil)

UIView.animate(withDuration: 0.5, delay: 0.6, options: [], animations: {
self.prtl.center.x -= self.view.bounds.width
}, completion: nil)
.
.
}

如何停止动画重新开始以防止屏幕上的按钮松动。

谢谢!

最佳答案

override func viewDidLoad() {
super.viewDidLoad()

std.center.x += view.bounds.width
prtl.center.x += view.bounds.width
.
.
UIView.animate(withDuration: 0.5, delay: 0.5, options: [], animations: {
self.std.center.x -= self.view.bounds.width
}, completion: nil)

UIView.animate(withDuration: 0.5, delay: 0.6, options: [], animations: {
self.prtl.center.x -= self.view.bounds.width
}, completion: nil)
}

从 viewWillAppear 中删除代码并尝试此操作。

关于iOS 在按下时禁用动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41872878/

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