'overrideUserInterfaceStyle not working in AppDelegate

I'm building an iOS app with the newest version of Xcode.

If I set

overrideUserInterfaceStyle = .light

to a View Controller, it will get set to light mode, also if dark mode is enabled.

But If I put this code in AppDelegate like this:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    
    window?.overrideUserInterfaceStyle = .light
    
    return true
}

it doesn't work.

There are no errors. The app simply is in light mode or dark mode depending on the mode the device is in.

Why doesn't overrideUserInterfaceStyle work in AppDelegate? Is it because I'm using a Tab Bar Controller for my app? I don't think so.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source