Created
October 16, 2016 19:36
-
-
Save agibson73/7866c631771c9036896ca3957a6bb550 to your computer and use it in GitHub Desktop.
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 vw = UIView(frame: CGRect(x: 0, y: 0, width: 50, height: 50)) | |
vw.backgroundColor = UIColor.red | |
self.view.addSubview(vw) | |
vw.center = self.view.center | |
// Your code with delay | |
let spring = CASpringAnimation(keyPath: "position.y") | |
spring.toValue = vw.center.y - 200 | |
spring.damping = 10.0 | |
spring.initialVelocity = 8.0 | |
spring.duration = spring.settlingDuration | |
spring.beginTime = CACurrentMediaTime() + 5.0 | |
CATransaction.begin() | |
CATransaction.setCompletionBlock { | |
vw.layer.position.y = vw.center.y - 200 | |
} | |
vw.layer.add(spring, forKey: nil) | |
CATransaction.commit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment