2
比方說,我有一個水平長的矩形。這是藍色的。我想它是紅色的。但是,我希望顏色變化從一側開始,另一側結束。動畫背景顏色變化 - 左右對角
我可以使用關鍵幀動畫使整個視圖從紅色逐漸變爲藍色。有沒有辦法逐步從左/右/左 - 左改變?
UIView.animateKeyframesWithDuration(2.0 /*Total*/, delay: 0.0, options: UIViewKeyframeAnimationOptions.CalculationModeLinear, animations: {
UIView.addKeyframeWithRelativeStartTime(0.0, relativeDuration: 1/1, animations:{
self.view.backgroundColor = UIColor.redColor()
self.view.layoutIfNeeded()
})
},
completion: { finished in
if (!finished) { return }
})