0
這裏是我的代碼:如何重置iOS中的動畫?
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
cloud.center.x -= view.bounds.width
cloud1.center.x -= view.bounds.width
cloud2.center.x -= view.bounds.width
cloud3.center.x -= view.bounds.width
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
UIView.animate(withDuration: 12) {
self.cloud.center.x += self.view.bounds.width*2
UIView.animate(withDuration: 12, delay: 9, options: [],
animations: {
self.cloud1.center.x += self.view.bounds.width*2
},
completion: nil
)
UIView.animate(withDuration: 12, delay: 18, options: [],
animations: {
self.cloud2.center.x += self.view.bounds.width*2
},
completion: nil
)
UIView.animate(withDuration: 12, delay: 22, options: [],
animations: {
self.cloud3.center.x += self.view.bounds.width*2
},
completion: nil
)
}
}
我有哪個頁面離開我的動畫這只是停留在一個位置重置一切重做。如何重新設置動畫才能重新播放動畫?
我不想撤銷它,我想動畫做同樣的事情,當我按下按鈕 –
做同樣的事情?反向動畫?如果你想再次做同樣的事情,你必須首先將視圖放回原來的位置。你需要清楚地陳述你的目標。 –