Skip to content

Instantly share code, notes, and snippets.

@nh7a
Created October 21, 2015 17:36
Show Gist options
  • Save nh7a/363225f2018a014156da to your computer and use it in GitHub Desktop.
Save nh7a/363225f2018a014156da to your computer and use it in GitHub Desktop.
func keyboardWillShow(notification: NSNotification) {
let info = notification.userInfo!
let rect = (info[UIKeyboardFrameEndUserInfoKey] as! NSValue).CGRectValue()
let duration = info[UIKeyboardAnimationDurationUserInfoKey] as! Double
let curve = notification.userInfo![UIKeyboardAnimationCurveUserInfoKey] as! UInt
let opts = UIViewAnimationOptions(rawValue: curve << 16)
UIView.animateWithDuration(duration, delay: 0, options: opts, animations: {
self.bottomConstraint.constant = rect.height
self.view.layoutIfNeeded()
}) { (finish: Bool) in
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment