Disable the Default Dark Appearance on Your iOS App

What if you don’t want dark mode?

Ivano Di Gese
Oct 21 · 2 min read
Photo by William Carlson on Unsplash

Since Apple’s release of its new SDK and the eleventh release of Xcode, apps are encouraged to support the new iOS 13 dark mode. But what if we don’t want to use it?

If you run a project you were developing for iOS 12, your app will simply show dark UIViews on iOS 13, causing your labels to not be displayed correctly and ruining your light-mode conception of how your UI should appear.

There are a couple of ways to disable dark mode, which we’ll cover below.


1. Setting UIUserInterfaceStyle in Your Info.plist

The easiest way to force your app to show light interfaces is setting the in the Info.plist, specifying the preferred interface style.

<key>UIUserInterfaceStyle</key>
<string>Light</string>

Just rebuild the app, and you’ll see a light interface in the entire app.


2. Setting the overrideUserInterfaceStyle Property

Every UIViewController, UIView, and even UIWindow may respond to the set of this property — obviously making the UIView, the entire controller, or the main window showing the light interface.

You should wrap the set up into a conditional to avoid compilation problems:

if #available(iOS 13.0, *) {
// prefer a light interface style with this:
overrideUserInterfaceStyle = .light
}

This property can be set into the UIViewController on as well as into your app’s method of the AppDelegate.swift, accessing the optional property.

This strictly depends on your app architecture and the way you want the set to be work. You can either set the entire main window to adopt the light interface or use it in specific UIViewController instances.

That’s why you have to choose between …

window?.overrideUserInterfaceStyle = .light

… in AppDelegate. Or you can use:

view.overrideUserInterfaceStyle = .light

… inside your UIViewController. As you can see, the property name is always the same: .


Final Thoughts

Avoiding dark mode in your app could be the wrong idea. Your app should support the new dark mode to improve the UX of iOS 13 because your app should be in the context of the preferred style.

Most professional and popular apps released updates to support the dark mode, and I suggest forcing the light mode only if your app must conform to a light interface.

Better Programming

Advice for programmers.

Ivano Di Gese

Written by

Passionate IT skills on the run: keep calm, do your stuff and code better

Better Programming

Advice for programmers.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade