xcodelistswiftuiseparatorios14

How to remove List Separator lines in SwiftUI


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 :)


Solution

  • 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(UIColor.systemBackground)))
        }
    }