我的 list 如下所示:
List(viewModel.exerciseSelection, id: \.id) { exercise in
AddWorkoutDetailView(exerciseName: exercise.name, gifImage: exercise.gifUrl)
.listRowInsets(EdgeInsets())
.listRowBackground(Color.backgroundColor)
.swipeActions(allowsFullSwipe: false) {
Button(role: .destructive) {
} label: {
Label("Delete", systemImage: "trash.fill")
}
}
}
.listStyle(.plain)
.scrollContentBackground(.hidden)
.listRowBackground(Color.backgroundColor)
编辑: 我的整个视图 struct 如下:
NavigationStack {
ZStack {
Color.backgroundColor
.ignoresSafeArea()
VStack {
// some other stuff
List {
// my list from above
}
}
}
}
问题是,当My List
为空时,将有一个黑色背景,而不是我的自定义背景 colored颜色 ,后者在填充List
时存在.