user12616082
user12616082

Reputation:

Unable to change the dark mode on the SwiftUI

I tried toggle the dark mode, I know Swift 4 or 5 I use the code:

overrideUserInterfaceStyle = .dark

But in SwiftUI, seem nothing way I can do that...how can I toggle the dark mode rest of app? I tried do many method and search everywhere but couldn't find any luck. Even I tried use didSet but no luck, it give me the error.

Any suggestion?

Upvotes: 4

Views: 3414

Answers (1)

egmoll7
egmoll7

Reputation: 119

If you want to force dark mode for the whole app you can add the User Interface Style to the Info.plist and set it to Dark

enter image description here

You can also add the following line to the Scene/App Delegate

window?.overrideUserInterfaceStyle = .dark

Upvotes: 5

Related Questions