swiftswiftuiwidget

WidgetKit safeArea issue


enter image description here I'm creating Widget for iOS app by using WidgetKit but I faced one problem width padding or safeArea here is code and output is like this but I want to cover all view by red

ZStack {
            Color.red
                .ignoresSafeArea()
        }.ignoresSafeArea()

I want to cover red color all view


Solution

  • Use this to set the background of your widget:

    YourWidgetView()
        .containerBackground(for: .widget) { Color.red }