1

Is there a way to show dark mode and light mode side by side in Xcode 11? I'm using UIKit / UIViewControllers.

( Using SwiftUI and previews this can be done but does not apply to UIKit:

#if DEBUG
struct ContentView_Previews: PreviewProvider {
   static var previews: some View {
      Group {
         ContentView()
            .environment(\.colorScheme, .light)

         ContentView()
            .environment(\.colorScheme, .dark)
      }
   }
}
#endif

)

Jonny
  • 15,955
  • 18
  • 111
  • 232

1 Answers1

0

When you use Storyboards, you can change the Interface Style of the preview. When running, you can use the Environment Overrides to toggle between light and dark mode. But both option won't show the view side-by-side.

What you can probably do is to wrap your UIKit view in a helper SwiftUI View using UIViewRepresentable and display that in the preview canvas. That should work for embedded UIKit content.

Frank Rupprecht
  • 9,191
  • 31
  • 56