Last active
August 1, 2018 22:22
-
-
Save meyusufdemirci/a9c9d3581cce00f046b324deb475254c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| @objc func keyboardWillShow(_ notification: Notification) { | |
| if let keyboardFrame = notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue { | |
| let keyboardRectangle = keyboardFrame.cgRectValue | |
| keyboardHeight = keyboardRectangle.height | |
| } | |
| if view.frame.origin.y == 0 { | |
| let animationDuration = notification.userInfo?[UIKeyboardAnimationDurationUserInfoKey] | |
| UIView.animate(withDuration: animationDuration as! TimeInterval) { | |
| self.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: (self.view.window?.frame.height)! - self.keyboardHeight) | |
| self.view.layoutIfNeeded() | |
| } | |
| } | |
| } | |
| @objc func keyboardWillHide(_ notification: Notification) { | |
| UIView.animate(withDuration: 0.2) { | |
| self.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: UIScreen.main.bounds.height) | |
| self.view.layoutIfNeeded() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment