Skip to content

Instantly share code, notes, and snippets.

@dasdom
Created December 5, 2016 21:35
Show Gist options
  • Save dasdom/25beeb632290fdadf061653ae9426066 to your computer and use it in GitHub Desktop.
Save dasdom/25beeb632290fdadf061653ae9426066 to your computer and use it in GitHub Desktop.
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
labelTopConstraint.constant = -40
labelUsernameConstraint.constant = -40
usernamePasswordConstraint.constant = -40
passwordButtonConstraint.constant = -40
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let duration = 0.5
let delay = 0.1
let damping = CGFloat(0.6)
let springVelocity = CGFloat(0.0)
labelTopConstraint.constant = 30
UIView.animate(withDuration: duration,
delay: 0.0,
usingSpringWithDamping: damping,
initialSpringVelocity: springVelocity,
options: [],
animations: {
self.view.layoutIfNeeded()
}, completion:nil)
labelUsernameConstraint.constant = 8
UIView.animate(withDuration: duration,
delay: delay,
usingSpringWithDamping: damping,
initialSpringVelocity: springVelocity,
options: [],
animations: {
self.view.layoutIfNeeded()
}, completion: nil)
usernamePasswordConstraint.constant = 8
UIView.animate(withDuration: duration,
delay: delay*2,
usingSpringWithDamping: damping,
initialSpringVelocity: springVelocity,
options: [],
animations: {
self.view.layoutIfNeeded()
}, completion: nil)
passwordButtonConstraint.constant = 8
UIView.animate(withDuration: duration,
delay: delay*3,
usingSpringWithDamping: damping,
initialSpringVelocity: springVelocity,
options: [],
animations: {
self.view.layoutIfNeeded()
}, completion: nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment