Can't change the iOS14 widget background color

You need to specify full frame, as on below demo

demo

StaticConfiguration(
    kind: "xWidget",
    provider: xProvider(),
    placeholder: Text("Loading...")) { entry in
    xWidgetEntryView(entry: entry)
       .frame(maxWidth: .infinity, maxHeight: .infinity)    // << here !!
       .background(Color.green)
}.supportedFamilies([.systemSmall, .systemMedium, .systemLarge])

If you want to change the background color of your widget, you should modify your Assets.xcassets.

The Assets.xcassets in the Widget target has a Color Set named "WidgetBackground".

Changing the "WidgetBackground" color not only changes the background color of your widget, but also the background color of the add button of the widget that appears in the Widget Library.

enter image description here


You can also set a color within your widget view using a ZStack like so:

var body: some View {
        
       VStack {
            ZStack {
                Color.black
                    .ignoresSafeArea()
                Link(destination: Deeplink.image.url!) {
                    Image("exampleImage")
                        .resizable()
                        .aspectRatio(contentMode: .fit)
                        .padding(.vertical, 3)
                }
            }
            Text("Example text")
        }
    }