1

I just want to set a Color as background color to my list. Can't find anything that work,

It looks like is not possible, I don't want to change every single color of my row.

Any tips how to do it? Looks like SwiftUI and List don't allow the background color, it allow only color per single raw.

struct ContentView: View {
    var body: some View {
        ZStack {
            RadialGradient(gradient: Gradient(colors: [.orange, .red]), center: .center, startRadius: 100, endRadius: 470).edgesIgnoringSafeArea(.all)
                .overlay(
                    List(0 ..< 5) { item in
                        Text("Test")
                    }
            )
        }
    }
}
Harshal Bhavsar
  • 1,598
  • 15
  • 35
Damiano Miazzi
  • 1,514
  • 1
  • 16
  • 38

1 Answers1

3

You can add

init() {
    UITableView.appearance().backgroundColor = .clear
    UITableViewCell.appearance().backgroundColor = .clear 
}

to your struct and then set background for your list.

Harshal Bhavsar
  • 1,598
  • 15
  • 35
Mac3n
  • 4,189
  • 3
  • 16
  • 29