I am using this code to move a UIImage along a curve:
    // paint curve for sun
    let path = UIBezierPath()
    let imageSunName = "small_sun.png"
    let imageSun = UIImage(named: imageSunName)
    let imageView = UIImageView(image: imageSun!)
    imageView.frame = CGRect(x: xStart, y: yStart, width: 24, height: 24)
    self.view.addSubview(imageView)
    path.moveToPoint(CGPoint(x: xStart,y: yStart))
    path.addQuadCurveToPoint(CGPoint(x: xEnd, y: yEnd), controlPoint: CGPoint(x: xMiddleTop, y: yMiddleTop))
    let animation = CAKeyframeAnimation(keyPath: "position")
    animation.path = path.CGPath
    animation.repeatCount = 0
    animation.duration = 5.0
    imageView.layer.addAnimation(animation, forKey: "animate position along path")
Nevertheless, two issues remain:
Cheers
To avoid jump to its original position add:
animation.fillMode = kCAFillModeForwards
animation.removedOnCompletion = false
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With