Skip to content

Instantly share code, notes, and snippets.

@sagaya
Last active January 20, 2019 15:37
Show Gist options
  • Save sagaya/13f48179e19fc49d23d27091813cbc5d to your computer and use it in GitHub Desktop.
Save sagaya/13f48179e19fc49d23d27091813cbc5d to your computer and use it in GitHub Desktop.
iOS animate along curve
let animation = CAKeyframeAnimation(keyPath: "position")
animation.path = bezierPath.cgPath
animation.repeatCount = 0
animation.duration = 3.0
animation.delegate = self
movingView.layer.add(animation, forKey: "animate along path")
movingView.center = CGPoint(x: 0, y: frame.maxY)
timer = Timer.scheduledTimer(timeInterval: 0.01, target: self, selector: #selector(fireTimer), userInfo: nil, repeats: true)
movingView.transform = CGAffineTransform(scaleX: 0.5, y: 0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment