Andrei Herford
Andrei Herford

Reputation: 18795

Is it possible to manually set / toggle the UserInterfaceStyle / Dark Mode per App?

I have updated my iOS 11+ to support Dark Mode when being used on iOS 13. This works fine when the UserInterfaceStyle / Dark Mode is enabled or disable in the device settings.

However, I would like to give users the option to activate / deactivate Dark Mode for my app only.

Using a switch to override / toggle the UserInterfaceStyle of the current app window is no big deal:

if #available(iOS 13.0, *) {
    for window in UIApplication.shared.windows {
        window.overrideUserInterfaceStyle = (uiStyleSwitch.isOn ? .dark : .light)
    }
}

But this approach has two one downsides:

So the question is: Is it possible to dynamically override the UserInterfaceStyle for the complete app?

I know that I can choose the style in the Info.plist but this cannot be changed by the user of course.

Upvotes: 1

Views: 1076

Answers (1)

shim
shim

Reputation: 10158

Use .unspecified to revert to the system settings for the interface style.

Choose this option when you want to follow the system's interface style

As for the other part of your question, it would probably depend on what is being presented and what callbacks you can access.

Upvotes: 3

Related Questions