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")
网友评论