Disabling Dark Mode on Widget in XCode 12 ( SwiftUI)

- After Apple brought in the Dark Mode Feature, there are some people that like their app just how they are and not converted in Dark Mode.

Jung Cha
Nov 24, 2020

- In order to change or disable Dark Mode in your app you can just create a property in the info.plist called ‘UIUserInterfaceStyle’ or now they changed it to ‘Appearance’.

# However this does not apply the same on Widgets

# On widgets, changing the info.plist does work and instead we use:

.environment(\.colorScheme, .light)

# For Example :

@main

struct testwidget: Widget {

let kind: String = “testwidget”

var body: some WidgetConfiguration {

IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider()) { entry in

testwidgetEntryView(entry: entry) .environment(\.colorScheme, .light)

}

.configurationDisplayName(“My Widget”)

.description(“This is an example widget.”)

}

}

--

--