I want to change the background color of all the keyboards appearing in my Phonegap/Cordova built native iOS App as shown below:
I have googled this thoroughly of course and found mainly 2 relevant answers. The answerer here says that Objective-C code can be added to the PhoneGap project's AppDelegate.m file as shown on this page. I've located the AppDelegate.m file but can't seem to figure out how to set the keyboard appearance to that of UIKeyboardAppearanceAlert on all textfields. Code example provided by the answerer:
mytextfield.keyboardAppearance = UIKeyboardAppearanceAlert;
Writing an app based on cordova, I can't distinguish any textfield IDs to connect to the above example. Is there a file in Xcode / Cordova in which all the textfield IDs are listed, or even better:
Is there a way in which I can set the keyboard appearance to dark through UIKeyboardAppearanceAlert or similar approaches, that applies to all textfields and is compatible with Cordova?
Thanks
After sharing this question widely on various social media, more extensive and thorough research, asking friends and aquaintances, etc I can only come to the conclusion that this cannot be done using phonegap and cordova. I would love for anyone to prove me long. For the time being however, this is what I shall conclude.
As far as I know you can't do that with Cordova without major hacks, which probably won't be appreciated by Apple. But not sure.
There is no way to apply it to ALL text fields in your app without going through your code and manually setting the style of each uitextfields keyboard to the dark one.
EDIT 2: Unfortunately, it doesn't look like there's any possible way to do this without tapping into the Phonegap framework. And It doesn't look like this is possible without "hacking" into it as mentioned above.
EDIT: There doesn't seem to be any HTML element for the input tag (from Apple's Mobile Safari or Phonegap) that you can set to make the appearance into a alert. So (if possible) do a search for UITextField *.
And right under the line that should look somewhat like this:
UITextField *field = [[UITextField alloc] init...];
Add this line
field.keyboardAppearance = UIKeyboardAppearanceAlert; // just like in your example...
If you do this for all the UITextField results then all your keyboards will look like the picture in your description.
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