Skip to content

Instantly share code, notes, and snippets.

@andresr-dev
Created March 25, 2023 19:23
Show Gist options
  • Save andresr-dev/235c8d118394d74c7621f78cf902c910 to your computer and use it in GitHub Desktop.
Save andresr-dev/235c8d118394d74c7621f78cf902c910 to your computer and use it in GitHub Desktop.
This is how to force dark mode in your application when the SwiftUI .preferedColorScheme() is not enough
let scenes = UIApplication.shared.connectedScenes
guard let scene = scenes.first as? UIWindowScene else { return }
scene.keyWindow?.overrideUserInterfaceStyle = .dark
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment