How to disable Dark Mode in iOS?
To disable the dark mode in iOS — Since iOS 13 and later (Xcode 11 or later)
Every app has dark mode enabled by default. But, if you are not ready to adopt it, you can disable it.
There is two way of doing it.
- Disable dark mode in the entire app
- Disable dark mode in the particular screens or view controllers
Let’s discuss those in detail.
Disable dark mode in the entire app
To control an interface style for an entire app, just simply set UIUserInterfaceStyle (Appearance) key in your Info.plist file.
You can assign it to either Light
or Dark
value to force a light and dark user interface style.
<key>UIUserInterfaceStyle</key>
<string>Light</string>
Set Appearance (UIUserInterfaceStyle) key to Light will disable dark mode for an entire app.
Disable dark mode in the particular screens or view controllers
You can also disable dark mode in both UIView and UIViewController.
# UIView
UIView got overrideUserInterfaceStyle
property to control an interface style. When you assign a value to a view overrideUserInterfaceStyle
property, the style applies to the view and all of the subviews owned by the same view controller.
view.overrideUserInterfaceStyle = .light
# UIViewController
Just like views, view controllers also get the overrideUserInterfaceStyle
property. If you assign a value to a view controller overrideUserInterfaceStyle
property, the new style applies to the view controller, its entire view hierarchy, and any embedded child view controllers.
override func viewDidLoad() {
super.viewDidLoad()
overrideUserInterfaceStyle = .light
}
So, if you want to disable dark mode for an entire view controller, you better set overrideUserInterfaceStyle
on a view controller.
TIP:- iOS Simulator can toggle between light and dark mode with
⌘ — command + ⇧ — shift + A shortcut.