A large part of my app consists of web views to provide functionality not yet available through native implementations. The web team has no plans to implement a dark theme for the website. As such, my app will look a bit half/half with Dark Mode support on iOS 13.
Is it possible to opt out of Dark Mode support such that our app always shows light mode to match the website theme?
The answer above works if you want to opt out the whole app. If you are working on the lib that has UI, and you don't have luxury of editing .plist, you can do it via code too.
If you are compiling against iOS 13 SDK, you can simply use following code:
Swift:
Obj-C:
HOWEVER, if you want your code to compile against iOS 12 SDK too (which right now is still the latest stable SDK), you should resort to using selectors. Code with selectors:
Swift (XCode will show warnings for this code, but that's the only way to do it for now as property does not exist in SDK 12 therefore won't compile):
Obj-C:
********** Easiest way for Xcode 11 and above ***********
Add this to info.plist before
</dict></plist>
I would use this solution since window property may be changed during the app life cycle. So assigning "overrideUserInterfaceStyle = .light" needs to be repeated. UIWindow.appearance() enables us to set default value that will be used for newly created UIWindow objects.
My app does not support dark mode as of now and uses a light app bar color. I was able to force the status bar content to dark text and icons by adding the following key to my
Info.plist
:Find the other possible values here: https://developer.apple.com/documentation/uikit/uistatusbarstyle
I think I've found the solution. I initially pieced it together from UIUserInterfaceStyle - Information Property List and UIUserInterfaceStyle - UIKit, but have now found it actually documented at Choosing a specific interface style for your iOS app.
In your
info.plist
, setUIUserInterfaceStyle
(User Interface Style) to 1 (UIUserInterfaceStyle.light
).EDIT: As per dorbeetle's answer, a more appropriate setting for
UIUserInterfaceStyle
may beLight
.According to Apple's session on "Implementing Dark Mode on iOS" (https://developer.apple.com/videos/play/wwdc2019/214/ starting at 31:13) it is possible to set
overrideUserInterfaceStyle
toUIUserInterfaceStyleLight
orUIUserInterfaceStyleDark
on any view controller or view, which will the be used in thetraitCollection
for any subview or view controller.As already mentioned by SeanR, you can set
UIUserInterfaceStyle
toLight
orDark
in your app's plist file to change this for your whole app.