Recently, Apple introduced Dark Mode–an alternative color scheme that darkens the user interface. In this blog post, I will show you how you can disable Dark Mode in your application until you can add support for it.
Dec 01, 2020 macOS Big Sur brings a ton of changes and new features and a small one is a tweak to where you can enable/disable Dark Mode on Mac. Read along for a look at several different ways to use Dark Mode.
If you are developing a new app or have plans to maintain your application into the future, then you should make plans to support Dark Mode. However, there are many valid reasons for needing to disable Dark Mode:
Supporting Dark Mode in your app is not a trivial task when you consider that designers, customers, and developers all have to pitch in to make it happen.
First, designers have to completely re-think the style of the app. How will each color behave in Light vs. Dark Mode? They may need to re-do images to maintain neutrality in both modes.
The customer also has to give feedback on how brand colors will be represented in both modes. Support for iOS 10 may have to be dropped in order to make the development of Dark Mode easier, so they will have to make considerations on how many users they still have on iOS 10.
Finally, the developer has to implement Dark Mode. It’s not a hard task–but a tedious one.
Any apps developed before iOS 13 will automatically have Dark Mode disabled. Now that iOS 13 has been released, if you submit an update to that app, the app will try to reverse your colors when in Dark Mode. What you end up with is a hybrid Light/Dark Mode app that does not look good.
The simplest way to disable Dark Mode is to add the
User Interface Style setting to your info.plist file and give it a value of
The XML representation of these settings is the following:
For another approach, in your AppDelegate file, set the window property
.light. This property is only available if running on iOS 13, so we can add an
#available condition so that we can only set it when available.
If you need to selectively disable Dark Mode for a view controller, instead of setting the
overrideUserInterfaceStyle property on the window, set it on the view controller instead.
If you are still running Xcode 10.x, then the above solutions will not compile, since 10.x does not know about iOS 13. You need to add some additional code.
There were some reports that developers were not able to submit their app to the app Store when they set the info.plist key UIUserInterfaceStyle. The submission process would give them an error of “unknown plist key.” However, this happened when iOS 13 was still in beta and Apple was not allowing submissions of apps using iOS 13 APIs. Now that iOS 13 is out, there is no problem with the submission process.
Even though Apple would like you to implement Dark Mode, it is not a strict requirement as of now. If possible, you should implement Dark Mode and not disable it. However, this solution is here if you need it.