Last active
February 24, 2020 08:36
-
-
Save blazovics/447b421bd6ff187fce8995280351a343 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 private func keyboardWillShow(notification: Notification) { | |
if | |
let userInfo = notification.userInfo, | |
let keyboardSize = (userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue, | |
let duration = (userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue | |
{ | |
if passwordTextField.frame.maxY > view.frame.height - keyboardSize.height { | |
UIView.animate(withDuration: duration, animations: { self.imageViewTopConstraint.constant -= | |
keyboardSize.height | |
self.view.layoutIfNeeded() | |
}) | |
} | |
} | |
} |
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 private func keyboardWillHide(notification: Notification) { | |
if | |
let userInfo = notification.userInfo, | |
let duration = (userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue | |
{ | |
UIView.animate(withDuration: duration, animations: { self.imageViewTopConstraint.constant = | |
UIDevice.current.orientation == .portrait ? 160 : 40 | |
self.view.layoutIfNeeded() | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment