Skip to content

Instantly share code, notes, and snippets.

@onmyway133
Created August 28, 2014 10:04
Show Gist options
  • Save onmyway133/197058d3fdc747626239 to your computer and use it in GitHub Desktop.
Save onmyway133/197058d3fdc747626239 to your computer and use it in GitHub Desktop.
visibleKeyboardHeight
// SVProgressHUD
- (CGFloat)visibleKeyboardHeight {
UIWindow *keyboardWindow = nil;
for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
if(![[testWindow class] isEqual:[UIWindow class]]) {
keyboardWindow = testWindow;
break;
}
}
for (__strong UIView *possibleKeyboard in [keyboardWindow subviews]) {
if([possibleKeyboard isKindOfClass:NSClassFromString(@"UIPeripheralHostView")] || [possibleKeyboard isKindOfClass:NSClassFromString(@"UIKeyboard")])
return possibleKeyboard.bounds.size.height;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment