'Keyboard does not change appearance in iOS dark mode
I am testing Dark Mode in iPhone 12 Pro (iOS 14.4). I enabled Dark Mode in Settings but my Keyboard remains the same. It does not appear in DarkMode.
I have 2 questions:
Do we need to write code to change the appearance of the Keyboard or OS assigns the appearance to Keyboard from Settings. (Android does this way).
If developer needs to handle the DarkMode appearance for keyboard then how can we do that?
I tried this code to change the color of the Keyboard in AppDelegate but it did not work.
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
[ConfigManager setup];
self.viewController = [[MainViewController alloc] init];
BOOL result = [super application:application didFinishLaunchingWithOptions:launchOptions];
// This is the code for changing the appearance of the keyboard
[UITextField appearance].keyboardAppearance = UIKeyboardAppearanceDark;
return result;
}
It's a Cordova based project and I am using CDVIonicKeyBoard Plugin.
Solution 1:[1]
In your code you are setting the standard system keyboard appearance to dark mode.
But if you are using Cordova based project and using CDVIonicKeyBoard Plugin, then you have to set the CDVIonicKeyBoard style to dark mode.
As I see from gitHub https://github.com/ionic-team/cordova-plugin-ionic-keyboard
They have provided information on how to set the Keyboard style programmatically to either dark or light mode.
// Possible values for 'KeyboardStyle'
Keyboard.setKeyboardStyle('light'); // <- default
Keyboard.setKeyboardStyle('dark');`
By default they set the keyboard style to light mode. To see the CDVIonicKeyBoard also in dark mode set the keyboard style to dark mode.
Solution 2:[2]
No, if you’re using the default keyboard provided by the system.
The method you used would work fine, but not if you’re using a third party framework’s keyboard.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Nandish |
Solution 2 | Daria |