Remove extra line separators below List in SwiftUI

后端 未结 10 1873
予麋鹿
予麋鹿 2020-12-13 00:25

I\'ve created a simple List as below, but there are extra separators below it.

List {
  Text(\"Item 1\")
  Text(\"Item 2\")
  Text(\"Item 3\")
         


        
10条回答
  •  再見小時候
    2020-12-13 00:42

    Try this, if you want to use the section, There's still a footer visible with this:

    List {
        Section(footer: Text("")) {
            Text("My text")
        }
        EmptyView()
    }
    

    I came up with a hacky way to hide footer in case you don't have any section:

    List {
        Text("Item 1")
        Text("Item 2")
    
        // Adding empty section with footer
        Section(footer:
            Rectangle()
                .foregroundColor(.clear)
                .background(Color(.systemBackground))){EmptyView()}
                .padding(.horizontal, -15)
    }
    

提交回复
热议问题