Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change height of iOS custom keyboard?

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?

like image 249
smecperson Avatar asked Feb 18 '15 02:02

smecperson


People also ask

How do I change the keyboard height on iOS?

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.

What is the height of keyboard in iOS?

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.

How do I customize my keyboard iOS?

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.

Can you customize iPhone keyboards?

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.


2 Answers

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.

like image 183
Meseery Avatar answered Oct 17 '22 14:10

Meseery


You're gonna want to check out this site. It provides a lot of information! custom keyboard

like image 1
user2277872 Avatar answered Oct 17 '22 13:10

user2277872