我一直有很多麻烦。我试图让4个按钮从屏幕外进来。最初它可以工作,但是,我有一个单独的按钮,后来改变按钮图像(想想琐事游戏)。我只是希望它们像下面一样动画并完成它。但它们似乎正在消失并显示出我无法解释的行为。按钮动画是不好的做法?我是否需要以某种方式声明按钮新的中心原点?
override func viewDidLayoutSubviews() {
ButtonA.center = CGPointMake(ButtonA.center.x - 100, ButtonA.center.y)
ButtonB.center = CGPointMake(ButtonB.center.x - 100, ButtonB.center.y)
ButtonC.center = CGPointMake(ButtonC.center.x - 100, ButtonC.center.y)
ButtonD.center = CGPointMake(ButtonD.center.x - 100, ButtonD.center.y)
}
override func viewDidAppear(animated: Bool) {
UIView.animateWithDuration(0.2, animations: {
self.ButtonA.center = CGPointMake(self.ButtonA.center.x + 100, self.ButtonA.center.y)
})
UIView.animateWithDuration(0.4, animations: {
self.ButtonB.center = CGPointMake(self.ButtonB.center.x + 100, self.ButtonB.center.y)
})
UIView.animateWithDuration(0.6, animations: {
self.ButtonC.center = CGPointMake(self.ButtonC.center.x + 100, self.ButtonC.center.y)
})
UIView.animateWithDuration(0.8, animations: {
self.ButtonD.center = CGPointMake(self.ButtonD.center.x + 100, self.ButtonD.center.y)
})
}
在调试器中追踪问题的原因也很困难。即使有突破点,我也无法达到他们消失的程度。它需要我汇编代码。