I made it working using:
AccessoryWidgetBackground()
.containerBackground(for: .widget) {
EmptyView()
}
If you plan to support older versions prior to iOS 17 I'm using this custom modifier:
extension View {
func widgetBackground(_ backgroundView: some View) -> some View {
if #available(iOSApplicationExtension 17.0, *) {
return containerBackground(for: .widget) {
backgroundView
}
} else {
return background(backgroundView)
}
}
}
and using it instead of .containerBackground()