Search code examples
iosipadios13ios-darkmode

iPad detect if the user has Dark Mode enabled, without supporting Dark Mode


I'm working on an iPad app. I would like to know if a user has Dark Mode turned on, without actually supporting Dark Mode.

When I have my iPad in Dark Mode, and I ask the O.S for the userInterfaceStyle it always returns 1 (Light Mode).

In my info.plist I've set the User Interface Style to Light. When I remove this value, asking the O.S for the userInterfaceStyle, I get the correct value.

I understand that we should "just support it", however I need evidence that user's are actually using it before I can allocate the resources necessary to complete the task.


Solution

  • When you set the info.plist key, the style will be overridden on the system level and your app will never receive the user's setting.

    Alternatively, you could remove the plist key and instead set overrideUserInterfaceStyle on your main window. All subviews of that window will render in light appearance, but you should be able to check for the system style.

    By the way, I think a lot of users are using Dark Mode by now, so it's probably worth the effort.