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

后端 未结 6 736
谎友^
谎友^ 2020-12-15 17:07

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().sep

6条回答
  •  再見小時候
    2020-12-15 18:05

    Merged @asperi, @akmin and @zrfrank answer into one thing. In my experience List is more reliable and efficient than LazyVStack, so I use still use List for anything complex requiring reliability.

    extension View {
        func listRow() -> some View {
            self.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading)
                .listRowInsets(EdgeInsets(top: -1, leading: -1, bottom: -1, trailing: -1))
                .background(Color(.systemBackground))
        }
    }
    
    List {
        Color.red
             .listRow()
    
    
        Color.green
             .listRow()
    }
    

提交回复
热议问题