幾個小時我一直試圖解決最小的動畫故障。我的代碼成功地將視圖從屏幕上移開,然後將其再生成動畫。它獲得了x座標,但Y軸的行爲我不明白。下面的代碼:iOS動畫故障,Y座標問題
func listTrans_slideIn (slideFrom: String) {
//var newFrame = tableView.frame
tableView.frame.origin.x = 1000
//tableView.frame.origin.y = 100
print("Table pushed to side")
UIView.animateKeyframesWithDuration(1.375 /*Total*/, delay: 0.0, options: UIViewKeyframeAnimationOptions.CalculationModeLinear, animations: {
UIView.addKeyframeWithRelativeStartTime(0.0, relativeDuration: 1/1, animations:{
self.tableView_toTLG_Top.constant = 130
self.tableView_toSV_Left.constant = 0
self.tableView_toSV_Right.constant = 0
self.setupView()
//newFrame.origin.y = self.hdrBox.frame.height+50
//newFrame.origin.x = 0
//self.tableView.frame = newFrame
self.tableView.layoutIfNeeded()
})
},
completion: { finished in
if (!finished) { return }
})
}
怪異的行爲是,如果我把正確的動畫關鍵幀y座標,它有太高,但隨後在正確的座標平息。如果我輸入的座標太低,它會進入正確的高度,但會降低。
正如你所看到的,我嘗試過使用框架和約束。我試過改變高度,我把它從屏幕上移開,但似乎沒有效果。
任何人都知道爲什麼我花了半天時間看到這個bug?