-1
当按下按钮时,我使用下面的代码将标签滑动到屏幕上,但它没有效果。当按下按钮时使用animateWithDuration但它没有效果(swift 2)
override func viewDidLayoutSubviews() {
summaryLabel.alpha = 0
}
@IBAction func searchButton(sender: AnyObject) {
UIView.animateWithDuration(2) {() -> Void in
self.summaryLabel.center = CGPointMake(self.summaryLabel.center.x - 400, self.summaryLabel.center.y)
self.summaryLabel.alpha = 1
self.summaryLabel.center = CGPointMake(self.summaryLabel.center.x + 400, self.summaryLabel.center.y)
}
//button code continues...
我测试过这是怎么回事以1固定α,但标签只是保持它是并按下按钮时不动。我错过了什么?
为什么你有两行代码改变self.summaryLabel.center –
我试图将按钮按下时,将标签(即alpha = 0)从屏幕上移开,然后将其带到视图中以2第二个动画 – Hikul
将第一行移动到动画块之外。或者创建两个不同的动画,但要小心第二个应该在第一个完成后才会发生 –