I've a UIBezierPath drawing this
And I want the red point to move on the blue path infinitely (from right to left, from left to right)
How can I do that?
I've a UIBezierPath drawing this
And I want the red point to move on the blue path infinitely (from right to left, from left to right)
How can I do that?
You can use CAKeyFrameAnimation
. Assign your path to the path
property of the animation object, then run the animation on the view's layer.
Edit:
A little snippet as a hint:
let path = ... // the UIBezierPath
let animation = CAKeyFrameAnimation()
animation.path = path.CGPath
animation.calculationMode = kCAAnimationPaced // This give the animation an even pace
animation.repeatCount = HUGE // This makes the animation repeat forever
viewToAnimation.layer.addAnimation(animation, forKey: nil)