The following code was pulled from another SO answer, but is it possible to delay the start of this CAKeyframeAnimation
animation similar to how UIView's animateWithDuration
offers a delay
property?
Based on the class docs, the CAKeyframeAnimation
class doesn't seem to contain a delay property.
let animation = CAKeyframeAnimation(keyPath: "transform.translation.x")
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
animation.duration = 1.0
animation.repeatCount = 2
animation.values = [-10, 10, -10, 10, -5, 5, -2, 2, 0]
view.layer.addAnimation(animation, forKey: "shake")