Last active
January 20, 2019 15:37
-
-
Save sagaya/13f48179e19fc49d23d27091813cbc5d to your computer and use it in GitHub Desktop.
iOS animate along curve
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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