Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get rid of the background color in iOS lock screen widget?

Using the following code:

    var body: some View {
        switch widgetFamily {
        case .accessoryInline:
            inlineAccessory
        case .accessoryRectangular:
            rectangularAccessory
        case .systemLarge,.systemMedium:
            homeScreenWidget
        default:
            EmptyView()
        }
    }

    var rectangularAccessory: some View {
        ViewThatFits {
            VStack (alignment: .leading){
                Text("\(entry.listVM.datedList.results.displayName)")
                    .font(.headline)
                
                Text("#1: \(entry.listVM.datedList.results.books[0].title)")
                    .font(.body)
            }
        }
    }

I get a lock screen widget with a gray background.

enter image description here

I have tried adding AccessoryWidgetBackground(), .backgoundStyle(.clear) and everything else I could think of, but I can never get rid of that gray background. I have changed the wallpaper and still it remains.

Any ideas?

like image 772
Ferdinand Rios Avatar asked Sep 04 '25 17:09

Ferdinand Rios


1 Answers

remove WidgetBackground in StaticConfiguration

.background(Color("WidgetBackground")) <<<< remove

like image 88
ĢhāŁı Вяанім Avatar answered Sep 07 '25 18:09

ĢhāŁı Вяанім