我正在尝试为两个文本字段和一个标签创建动画幻灯片。然而,出于某种原因,每次您尝试单击文本字段时,viewDidAppear() 函数都会运行,导致它们继续动画。有人有什么想法吗?
这是我的函数代码:
override func viewDidAppear(animated: Bool)
{
//Some Code here
UIView.animateWithDuration(1.5, delay: 0.5,
usingSpringWithDamping: 0.3,
initialSpringVelocity: 0.5,
options: [], animations: {
self.Email.center.x += 475
self.Password.center.x -= 400
}, completion: nil)
UIView.animateWithDuration(2.0, delay: 2.0,
options: [],
animations: {
self.LoginButton.alpha = 1.0
}, completion: nil)
UIView.animateWithDuration(1.5, delay: 0.5,
usingSpringWithDamping: 0.3,
initialSpringVelocity: 0.5,
options: [], animations: {
self.LoginL.center.y += 100
}, completion: nil)
}
最佳答案
我们发现问题出在 ViewController 生命周期 - 它需要调用 super.viewDidAppear(animated)
。
关于swift - viewDidAppear() 在每次点击时运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42018323/