0

To disable dark mode for the iOS app, we can simply set UIUserInterfaceStyle in Info.plist to Light.

But how do I disable dark mode on specific UIViewController's?

Harshal Wani
  • 2,249
  • 2
  • 26
  • 41
iVictor
  • 25
  • 5
  • 2
    see this for help : https://stackoverflow.com/questions/56537855/is-it-possible-to-opt-out-of-dark-mode-on-ios-13 – Anbu.Karthik Jan 02 '20 at 06:08

3 Answers3

4

You can force viewController to act as you want. In viewDidLoad you have to follow this code to change UserInterfaceStyle

Objective-C

if (@available(iOS 13.0, *)) {
    [self setOverrideUserInterfaceStyle: UIUserInterfaceStyleLight];
}

Swift

if #available(iOS 13.0, *) {
    overrideUserInterfaceStyle = .light
}
PinkeshGjr
  • 8,460
  • 5
  • 41
  • 56
2

If you want to disable dark mode on specific view controllers than you have to put this code in viewcontroller's viewDidLoad method

    override func viewDidLoad() {
    super.viewDidLoad()
    // overrideUserInterfaceStyle is available with iOS 13
    if #available(iOS 13.0, *) {
        // Always adopt a light interface style.
        overrideUserInterfaceStyle = .light
    }
}

Dhaval Raval
  • 594
  • 2
  • 7
1
  • Instead of disabling it, you can use following code to make it look like it is disabled

    if #available(iOS 13.0, *)
    {
         self.view.overrideUserInterfaceStyle = .light
         // This will solve the problem (Current View will never be in dark mode
    
    }
    
Nayan Dave
  • 1,078
  • 1
  • 8
  • 30