I have a list in a sheet I'm presenting and I can't seem to set the background color on it. I can verify it's the list itself (rather than something to do with the background color of the sheet). If I set a max width on the list I can see the correct background color surrounding the edges of the list.
My sheet view is as follows
struct WorkoutView: View {
var body: some View {
ZStack {
// ...
}
.sheet(isPresented: $showSheet) {
ExercisesList()
}
}
}
struct ExercisesList: View {
init() {
UITableView.appearance().backgroundColor = .clear
UITableViewCell.appearance().backgroundColor = .clear
}
var body: some View {
List(exercises, id: \.self) { exercise in
HStack {
Button {} label: {
HStack {
Text(exercise)
.foregroundColor(.white)
Spacer()
}
}
.padding(.horizontal)
.padding(.vertical, 18)
}
.listRowInsets(
.init(
top: 0,
leading: 0,
bottom: 0,
trailing: 0
)
)
.listRowBackground(Color.black)
.listRowSeparatorTint(Color.white.opacity(0.2))
}
.listStyle(.plain)
.listRowBackground(Color.black)
.background(Color.black.edgesIgnoringSafeArea(.all))
}
}
I've also tried to put the List in a ZStack with a Color.black.edgesIgnoringSafeArea(.all)
, but since the list sits on top of the Color it's just displaying white underneath.
