How to remove List Separator lines in SwiftUI 2.0 in iOS 14

Osama Naeem picture Osama Naeem · Jun 26, 2020 · Viewed 8.1k times · Source

So the question is pretty simple and it's in the title. I want to remove the line separator in SwiftUI iOS 14. Previously, I was using UITableView().appearance().separatorStyle = .none and that used to do the job in iOS 13. Now however, it doesn't work. Any update or idea on how to make it work. Thanks:)

Answer

Asperi picture Asperi · Jun 26, 2020

Here is a demo of possible solution. Tested with Xcode 12b.

demo

List {
    ForEach(0..<3) { _ in
        VStack {
            Text("Hello, World!").padding(.leading)
        }
        .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
        .listRowInsets(EdgeInsets())
        .background(Color.white)
    }
}