我有一個subclassed imageview,我想淡入,放大和旋轉,然後繼續旋轉,同時縮小和淡出。UIView動畫 - 旋轉和放大,然後旋轉並縮小比例
我正在使用帶有完成處理程序的UIView動畫塊來處理收縮。
問題是這不是流動的動畫。在完成處理程序運行之前,動畫在再次運行之前停止。我需要它是動畫的一個很好的「一舉一動」。下面
代碼:
let duration: TimeInterval = 3.0
let rotate = CGAffineTransform(rotationAngle: CGFloat(Double.pi))
UIView.animate(withDuration: duration * 3, delay: 0, options: [.curveLinear], animations: {
// initial transform
self.alpha = 0
self.transform = CGAffineTransform(scaleX: 0.1, y: 0.1)
// initial spin for duration of animaton
UIView.animate(withDuration: duration * 3, delay: 0.0, options: [.curveLinear], animations: {
self.transform = rotate
}, completion: nil)
// scaling and fading
UIView.animate(withDuration: duration, delay: 0, options: [.curveLinear], animations: {
UIView.setAnimationRepeatCount(3)
self.transform = self.transform.scaledBy(x: 0.8, y: 0.8)
self.alpha = 1
}) { (true) in
UIView.animate(withDuration: duration, animations: {
UIView.setAnimationRepeatCount(3)
self.transform = self.transform.scaledBy(x: 0.1, y: 0.1)
self.alpha = 0
})
}
}, completion: nil)
我怎樣才能讓動漫旋轉整個時間而衰落和縮減下來,淡出前擴大?整個動畫應持續3秒,並重復3次。謝謝。 ()
你看着關鍵幀動畫? –
我同意Donnovan King的觀點......你應該從UIView動畫級下降到通過Core Animation直接完成的關鍵幀動畫。這將使您的整個動畫連續循環。 –
多諾萬和斯科特 - 通過關鍵幀動畫,你的意思是用cabasicanimation動畫? – Joe