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
let windowSafeArea: CGFloat = windowsSafeAreaWereAdded ? 0 : viewController.view.safeAreaInsets.bottom - viewController.additionalSafeAreaInsets.bottom | |
viewController.additionalSafeAreaInsets.bottom += beginKeyboardBounds.origin.y - endKeyboardBounds.origin.y - windowSafeArea | |
windowsSafeAreaWereAdded = true |
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
let duration = userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] | |
.flatMap { $0 as? Double } ?? 0.25 | |
if duration > 0 { | |
let curve = userInfo[UIResponder.keyboardAnimationCurveUserInfoKey] | |
.flatMap { $0 as? Int } | |
.flatMap { UIView.AnimationCurve(rawValue: $0) } ?? .easeInOut | |
UIViewPropertyAnimator(duration: duration, curve: curve) { | |
viewController.view.layoutIfNeeded() | |
} | |
.startAnimation() |
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
import Foundation | |
class KeyboardAppearListener { | |
private var showKeyboard: NotificationToken? | |
private var hideKeyboard: NotificationToken? | |
private weak var viewController: UIViewController? | |
private var windowSafeArea: CGFloat = 0 | |
private var windowsSafeAreaWereAdded = false |
OlderNewer