【问题标题】:How do you get rid of the background color in iOS lock screen widget?你如何摆脱iOS锁屏小部件中的背景颜色?
【发布时间】:2022-11-11 03:39:53
【问题描述】:

使用以下代码:

    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)
            }
        }
    }

我得到一个灰色背景的锁屏小部件。

我已经尝试添加 AccessoryWidgetBackground()、.backgoundStyle(.clear) 和我能想到的所有其他内容,但我永远无法摆脱那个灰色背景。我已经更换了墙纸,但它仍然存在。

有任何想法吗?

【问题讨论】:

    标签: swift swiftui widget ios16 lockscreenwidget


    【解决方案1】:

    在 StaticConfiguration 中删除 WidgetBackground

    .background(Color("Widget 背景")) <<<< 移除

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多