关键帧动画CAKeyframeAnimation
2017-03-15 本文已影响15人
歌手的剑
let anima: CAKeyframeAnimation = CAKeyframeAnimation(keyPath: "transform.translation.x")
let currentTx = self.centerHexaView.transform.tx
anima.duration = 1.2
anima.values = [currentTx, currentTx - 4.5, currentTx, currentTx + 4.5, currentTx]
anima.keyTimes = [0, 0.3, 0.6, 0.9, 1.2]
anima.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
self.centerHexaView.layer.add(anima, forKey: "kAFViewShakerAnimationKey")