Search code examples
iosswiftxcodeios13

How can I disable dark mode for all UIViewControllers without using Any BaseUIViewController?


I read Apple Article for disable Dark Mode because I need disable for my all UIViewController and i haven't any BaseUIViewController.

How can I disable Dark Mode for all UIViewController without using any BaseUIViewController? I don't want to write the following code over and over again.

Is there a solution to this?

override func viewDidLoad() {
    super.viewDidLoad()

    // Always adopt a light interface style.    
    overrideUserInterfaceStyle = .light
}

Solution

  • You can force light/dark mode in your whole application regardless of the user's settings by adding the key UIUserInterfaceStyle to your Info.plist file and setting its value to either Light or Dark.