方法調用動畫addSubview破壞動畫迅速
for button in self.exploreButtonsArray {
button.exploreButtonExitAnimation()
}
setupDrinkExploreButtons()
代碼爲動畫:
func exploreButtonExitAnimation() {
UIView.animateWithDuration(random, delay: 0.0, options: [], animations: {
self.center.x -= 400
}, completion: {(value: Bool) in
self.removeFromSuperview()
})
}
的setupDrinkExploreButtons()
方法調用.addSubview(exploreButton)
並增加了一些按鈕的容器。我的動畫是否搞亂了,因爲這些動作是異步執行的?
第一圖象:這是所有動畫
第二圖像之前的第一個觀點:如何視圖看起來不調用setupDrinkExploreButtons()。所有按鈕優雅地移動到左邊。
3圖像:它看起來什麼叫setupDrinkExploreButtons時像()
在你可以看到按鈕不會消失,但第3圖像,而不是他們似乎是「動畫的」,以適應視圖。他們似乎沒有像他們應該向左邊移動400個單位,而是突然出現了400個單位,然後向左移動以適應他們的原始位置?
你可能想檢查「隨機」的值,看看他們在適當的範圍值。 – Dasem
@Dasem動畫的問題不在於速度是隨機的。我已經做了一些截圖來演示問題是如何發生的。 – tryingtolearn