【发布时间】:2020-11-11 16:15:54
【问题描述】:
我知道我可以使用以下代码更改 SwiftUI 中的视图背景颜色:
.background(Color(.systemGroupedBackground))
但我不能为小部件背景颜色本身做到这一点!
我使用这个代码:
struct XWidget: Widget { // MARK: Widget is defined here
var body: some WidgetConfiguration {
StaticConfiguration(
kind: "xWidget",
provider: xProvider(),
placeholder: Text("Loading...")) { entry in
xWidgetEntryView(entry: entry).background(Color(.systemGroupedBackground)) // <= here
}.supportedFamilies([.systemSmall, .systemMedium, .systemLarge])
}
}
但是结果是这样的:
【问题讨论】:
标签: ios widget swiftui background-color