Updating UIKeyboardAppearance on keyboard display

Cocoa Touch allows you to change the appearance of the keyboard by setting the keyboardAppearance property of the UITextInputTraits protocol, which is implemented in the UITextField and UITextView classes.

It seems that updating the keyboardAppearance property when the keyboard is already on the screen does not update the appearance of the keyboard.

As a workaround, I decided to remove the keyboard and open it again. Is there a better way to solve the problem?

+4
source share
1 answer

This is an annoying limitation, I have the same requirement.

The only thing I could find was to call:

self.textView.resignFirstResponder()
self.textView.keyboardAppearance = UIKeyboardAppearance.Dark
self.textView.becomeFirstResponder()

, UIKeyboardWillShow/HideNotifications, contentInsets .., .

+1

Source: https://habr.com/ru/post/1544531/


All Articles