Lowering the iPhone / iPad Keyboard

I am writing a universal application that will be used mainly at night. I will need to display the keyboard, but I do not want the light colors of the keyboard to close my eyes and / or spoil the night vision. I don’t want you to face the problem of creating a custom keyboard, so I decided that the solution could be to place a UIView above the keyboard and give it a black background color with alpha 0.5 or something else, I can’t understand how to get uiview to cover keyboard. Does anyone know how to do this? Does Apple Allow This?

+4
source share
2 answers

The keyboard is in the form of a subzone of a new window, which is added when it appears. The search is a bit hacky and fragile (it will require verification in new versions of iOS, as it was before), but it works, and it is allowed (I do just that for night mode in the application located in the application store).

UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1]; // This assumes you aren't adding any new windows yourself for(UIView *keyboard in tempWindow.subviews) { if([[keyboard description] hasPrefix:@"<UIPeripheralHost"] == YES) // This was different in an earlier version of iOS, and may well change again in the future! { [keyboard addSubview:maskView]; break; } } 

This is done inside the method that responds to the UIKeyboardDidShowNotification object. I have not tried this on an iPad, this is just the iPhone code.

The mask view, as you say, is a simple view with a black background and some transparency. You can also use the warning keyboard style, which gives a black space between the keys.

This method, unfortunately, does not allow you to blink a little buttons (large keys that appear when you press a key).

+6
source

try applying the necessary changes to the inputView property inputView / UITextArea (the one that is used).

0
source

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


All Articles