I'm animating an object (CAShapeLayer) along a bezier path by pausing the animation and setting the timeOffset manually, which moves it to fixed locations. But the movement is jerky. I want to be able to set the next offset and have it interpolate/animate smoothly from spot to spot. This is essentially what I'm doing. What should I do to smooth out the transitions?
let bezierCurve = UIBezierPath(...)
let shapeLayer = getShape()
layer.speed = 0 // pause
.
.
.
let pathAnimation = CAKeyframeAnimation()
pathAnimation.keyPath = "position"
pathAnimation.path = bezierCurve.cgPath
pathAnimation.calculationMode = .paced
pathAnimation.fillMode = .forwards
pathAnimation.duration = 1
pathAnimation.isRemovedOnCompletion = false
pathAnimation.beginTime = CACurrentMediaTime()
shapeLayer.add(pathAnimation, forKey: nil)
layer.addSublayer(shapeLayer)
.
.
layer.timeOffset = pathAnimation.beginTime + n // note: periodically update n