Suyash
Suyash

Reputation: 415

how to Disable Dark mode in in my application

I just want override dark mode UI in my application. I added UIUserInterfaceStyle is Light. But i am not sure it is not working. Is there any other option?

Upvotes: 3

Views: 6069

Answers (3)

Rahul Panzade
Rahul Panzade

Reputation: 1372

You can force light or 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.

Upvotes: 3

Mojtaba Hosseini
Mojtaba Hosseini

Reputation: 119292

  • For entire App (Window):
window!.overrideUserInterfaceStyle = .light

You can get the window from SceneDelegate or any view.window

  • For a single ViewController:
viewController.overrideUserInterfaceStyle = .light

You can set any viewController, even inside the viewController itself

  • For a single View:
view.overrideUserInterfaceStyle = .light

You can set any view, even inside the view itself

You may need to use if #available(iOS 13.0, *) { ,,, } if you are supporting earlier iOS versions.

Upvotes: 5

Josep Escobar
Josep Escobar

Reputation: 456

For Objective C entire App:

_window.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;

Upvotes: 3

Related Questions