Skip to content

Instantly share code, notes, and snippets.

@marybnq
Created July 5, 2021 08:36
Show Gist options
  • Save marybnq/bfbee354d1846536ac5f17ae47703b12 to your computer and use it in GitHub Desktop.
Save marybnq/bfbee354d1846536ac5f17ae47703b12 to your computer and use it in GitHub Desktop.
A class containing the actual dimensions of the iOS keyboard
class Calculator {
/**
@return height of the view containing the keyboard buttons
*/
static func getKeyboardHeight()->CGFloat{
if UIDevice.current.userInterfaceIdiom == .phone {
// Portrait Landscape
return getWidth() < getHeight() ? 216 : 162
} else{
// Portrait Landscape
return getWidth() < getHeight() ? 265 : 353
}
}
/**
@return the height of the toolbar
*/
static func getToolbar() -> CGFloat{
if UIDevice.current.userInterfaceIdiom == .phone {
return getWidth() < getHeight() ? 45 : 38
}
//iPad
return 55
}
static func getWidth() -> CGFloat{
return UIScreen.main.bounds.width
}
static func getHeight() -> CGFloat{
return UIScreen.main.bounds.height
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment