How to remove the line separators from a List in SwiftUI without using ForEach?

前端 未结 13 1789
盖世英雄少女心
盖世英雄少女心 2021-01-30 04:50

I have this code to display a list of custom rows.

struct ContentView : View {
    var body: some View {
        VStack(alignment: .leading) {
            List(1         


        
13条回答
  •  死守一世寂寞
    2021-01-30 05:42

    All the answers tell you to use ScrollView (which is what I recommend too)

    But in case you want to use List and want to remove the separator lines..

    Install the SwiftPM: https://github.com/siteline/SwiftUI-Introspect

    SAMPLE:

    List {
        Text("Item 1")
        Text("Item 2")
    }
    .introspectTableView { tableView in
        tableView.separatorStyle = .none
    }
    

提交回复
热议问题