Unable to change preview to dark mode in SwiftUI (Xcode12)

253 views Asked by At

I'm unable to see preview in dark mode. In the preview, the font color gets changed to white from black (as per dark mode) but the background color of the view is still white (making the text invisible). It's working fine on simulator though. I've given any color to view or text from code. I'm using the same code as suggested in other answers

  struct Widget_Previews: PreviewProvider {
    static var previews: some View {
        Group {
            AvatarWidgetEntryView(entry: SimpleEntry(date: Date(), avatarWidgetData: widgetData)
                .previewContext(WidgetPreviewContext(family: .systemMedium))   
                .colorScheme(.dark)
            AvatarWidgetEntryView(entry: SimpleEntry(date: Date(), avatarWidgetData: widgetData))
                .previewContext(WidgetPreviewContext(family: .systemSmall))
        }
    }
 }
0

There are 0 answers