I've been working on an iOS custom keyboard (in an .xib file), but I haven't been able to change the height within storyboard. Is there a way to change the height of the keyboard within storyboard or do I have to find a way to do it programmatically?
There is no specific keyboard setting in iOS that allows you to increase the size of the keyboard key alone. You can verify this yourself by going to Settings > General > Keyboard. There's a lot of keyboard settings, but none for increasing key size.
The top of the keyboard needs to be about 2 inches from the bottom of the *device* as it is held. Prior to the iPhone X, this is easy because all devices used the exact same bezel insets, so it's 216 pts from the bottom of the screen.
Navigate to Settings > General > Keyboard > Keyboards > Add New Keyboard and select AC Custom Keyboard. This will add it to the list of available keyboards. Go back to your app and bring up the keyboard by tapping the text view. Tap and hold the globe key and select AC Keyboard from the list that pops up.
You can adjust the onscreen (software) keyboard on iPhone. If you use an external (hardware) keyboard with iPhone, you can customize keyboard shortcuts and change settings such as the key repeat rate.
Here's my solution as Apple Documentation Suggests :
You can adjust the height of your custom keyboard’s primary view using Auto Layout. By default, a custom keyboard is sized to match the system keyboard, according to screen size and device orientation. A custom keyboard’s width is always set by the system to equal the current screen width. To adjust a custom keyboard’s height, change its primary view's height constraint.
override func viewWillAppear(animated: Bool) {
let desiredHeight:CGFloat!
if UIDevice.currentDevice().userInterfaceIdiom == .Phone{
desiredHeight = 259
}else{
if UIDevice.currentDevice().orientation == .Portrait{
desiredHeight = 260
}else {
desiredHeight = 300
}
}
let heightConstraint = NSLayoutConstraint(item: view, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1.0, constant: desiredHeight)
view.addConstraint(heightConstraint)
}
documentation said ,you can adjust your keyboard height after being layout ,so you can use viewWillAppear
to do so.
You're gonna want to check out this site. It provides a lot of information! custom keyboard
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With