6

With the new XCode 13 and it‘s iOS 15 support the presentation of Lists have apparently changed. Now a List has an additional gray background. Before, the background was plain white, just as I would like it to be. When I add other elements like texts, the default background color is still white.

Is there any way to get rid of the gray surrounding of the List without switching to a ForEach() solution?

I tried changing the background color from gray to white on various places and adding additional stacks in hope to override the default background color.

This I want be be all white without the gray surrounding:

Example Image

struct ContentView: View {
    var body: some View {
        
        VStack {
            Text("Test")
            
            List {
                ForEach(1..<20) { i in
                    Text(String(i))
                }         
            }.frame(maxWidth: .infinity)                
        }       
        
    }
}
user9582784
  • 175
  • 1
  • 8

1 Answers1

16

Change the listStyle to .plain. The default for iOS 14 is .plain, and .insetGrouped for iOS 15.

Code:

struct ContentView: View {
    var body: some View {
        VStack {
            Text("Test")

            List {
                ForEach(1 ..< 20) { i in
                    Text(String(i))
                }
            }
            .listStyle(.plain)
        }
    }
}

Result:

Result

George
  • 25,988
  • 10
  • 79
  • 133
  • Good god this hurt, thank you for clarifying the painful default change. Dark/Light mode defaults on iOS15 are a hellish nightmare. Live and learn... ty. – moodboom Jul 25 '22 at 00:10