swiftuixcode13

List Row Separator visibility setting not working? Xcode 13


Seems as though the visibility setting for the separators on lists is not working.. anyone know of a simple workaround?

Here is a piece of sample code:

import SwiftUI

struct ContentView: View {
    var listData = ["John", "Mack", "Bush"]
    var body: some View {
        List(listData, id: \.self) { name in
            Text(name)
        }.listRowSeparator(.hidden)
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Solution

  • Try this

    List {
        ForEach(listData, id: \.self) { name in
            Text(name)
                .listRowSeparator(.hidden)
        }
    }