Created
September 11, 2020 21:10
-
-
Save AndreyAnt/d013be38f7b001b3fbc6bcddae5ea2df to your computer and use it in GitHub Desktop.
This file contains 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
var keyboardHeight: CGFloat { | |
let windows = UIApplication.shared.windows | |
guard let keyboardWindowClass = NSClassFromString("UIRemoteKeyboardWindow"), | |
let keyboardWindow = windows.first(where: { $0.isKind(of: keyboardWindowClass) }), | |
let rootViewController = keyboardWindow.rootViewController, | |
let keyboardViewClass = NSClassFromString("UIInputSetHostView"), | |
let keyboardView = rootViewController.view.subviews.first(where: { $0.isKind(of: keyboardViewClass) }) else { return 0 } | |
return keyboardView.frame.height | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment