WidgetKit background like the system battery widget

Hello, is it possible to configure our widgets with a background like the inbuilt system battery widget?

It looks like it's using a UIVisualEffectView as it's background which looks fantastic against the user's background. Especially as it transitions for dark mode.

I've been through all the docs and designing for WidgetKit but can't figure out how to have anything but a fully opaque background.

Setting the background to transparent on my SwiftUI view results in white showing as the background.

Thanks,

Greg
Would love to know this as well..
Can you try wrapping the UIVisualEffectView in a ViewRepresentable protocol and see if you can use it?
Yeah,I have this question,too.
Do you have any progress?
If it possible,could you tell me when you have a solution?
Thanks,
Littleor
Jjm
Me too
Would love to know the same!
watching this too
watching this too...
I tried wrapping UIVisualEffectView in a ViewRepresentable protocol, but that didn't work. The widget rendered with a large yellow/red forbidden image as background.
watching this too...
+1 👀
There is a related question https://developer.apple.com/forums/thread/653471 "Add UIKit view into iOS 14 Widget"

The reply: "UIKit views wrapped in UIViewRepresentable will not work in WidgetKit. When the views are encoded from your extension to be displayed they will appear blank. "


following but guessing this is an apple only thing that they might open up in official docs
前排插眼(谁说只能英文回复?)+1
Code Block swift
var body: some View {
        VStack{
            if self.family == .systemLarge {
                LargeEntryView()
            } else if self.family == .systemMedium {
                MediumView()
            } else {
                SmallView()
            }
        }.background(ContainerRelativeShape().fill(Color.init(.sRGB, red: 0.89, green: 0.89, blue: 0.89, opacity: 0.75)))
    }

works like charms.
WidgetKit background like the system battery widget
 
 
Q