0
votes

I want to disable dark mode within my app for iOS 13. And I prefer not to do so via info.plist. The reason is, plist uses a global setting, making UIUserInterfaceStyle affects earlier iOS versions aswell (creating conflicts). I only want to set it to light for iOS 13! This is my current code within my AppDelegate:

 if(@available(iOS 13, *)){
    window.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;

}

This code snippet works for fixing statusBar color to light. But general strings within the app are still in "dark mode". Earlier white strings turn into black, and my app is already pretty dark as it is. How do I fix so strings in the app does not change it's colors by themselves in dark mode? I want a global code snippet and not go through every ViewController...

Regards

2
“making UIUserInterfaceStyle affects earlier iOS versions aswell (creating conflicts)” No it doesn’t. Earlier iOS versions know nothing of this key, so they just disregard it. - matt

2 Answers

3
votes

iOS ignores Info.plist keys it doesn't know. So you can safely set UIUserInterfaceStyle to Light in your Info.plist, iOS prior to version 13 will ignore this key.

1
votes

Fixed the problem by calling:

    self.window.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;