How to animate NSView using keyframe

Issue #404

let animation = CAKeyframeAnimation(keyPath: "position.y")
animation.values = [50, 20, 50]
animation.keyTimes = [0.0, 0.5, 1.0]
animation.duration = 2
animation.repeatCount = Float.greatestFiniteMagnitude
animation.autoreverses = true
myView.wantsLayer = true
myView.layer?.add(animation, forKey: "bounce")
Written by

I’m open source contributor, writer, speaker and product maker.

Start the conversation