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

前端 未结 13 1762
盖世英雄少女心
盖世英雄少女心 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:43

    I started a project to solve this in iOS14 since the iOS 13 workarounds no longer work. It allows setting the separator style, separator color, and separator inset.

    Hide separators on the List

    List {  }
        .listSeparatorStyle(.none)
    

    Show a single divider line with configurable color and insets

    List {  }
        .listSeparatorStyle(.singleLine, color: .red, inset: EdgeInsets(top: 0, leading: 50, bottom: 0, trailing: 20)
    

    https://github.com/SchmidtyApps/SwiftUIListSeparator

提交回复
热议问题