Search code examples
swiftswiftuiwidgetios14widgetkit

Disable Light Mode in Widget Extension iOS 14


My app is supporting DarkMode only, and I'm doing integrate Widget for iOS 14.

Is there any way to disable the LightMode for Widget? (Already add UIUserInterfaceStyle in the main app .plist but doesn't work for Widget)

  • Stock's Widget always displaying DarkMode even in Editting mode.

Stock Widget always displaying DarkMode even in Editting Widget

I tried to use @Environment(\.colorScheme) var colorScheme but when open the Edit Mode of Widget, Light Theme still available.


Solution

  • Add the desired color to the widget’s asset catalog, then set the NSWidgetBackgroundColorName in your widget’s build settings.

    Docs: https://developer.apple.com/documentation/bundleresources/information_property_list/nswidgetbackgroundcolorname