Custom keyboard height is more than default keybao

2019-03-03 09:30发布

问题:

How to do the custom size of keyboard like what gBoard did in their keyboard (see the screenshot). Here the search section is showing above the keyboard. I want to do the same in my application. Is anybody can help me to know which method is using to create such a view.

回答1:

You should look at the inputAccessoryView property. Since it is a property on UIResponder, it is available on UITextView, UITextField and others. Assigning your custom view to inputAccessoryView will make it appear on top of the keyboard whenever the UI object you assigned it to has focus.

// Create your custom keyboard accessory view first
// then assign it
yourTextField.inputAccessoryView = yourCustomAccessoryView;

// Bring up keyboard and your accessory view
[yourTextField becomeFirstResponder];

Read more here https://developer.apple.com/library/content/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/InputViews/InputViews.html

inputAccessoryView
Assigning a view to this property causes that view to be displayed above the standard system keyboard (or above the custom input view if one is provided) when the text view becomes the first responder. For example, you could use this property to attach a custom toolbar to the keyboard.