Remove top separator line in ListView

Viewed 69

I have the following code:

var body: some View {
    VStack {
        List {
            SearchBar(text: $searchText, placeholder: "Place Holder")
                .background(Color.white)
                .listRowInsets(.init(top: 0, leading: 0, bottom: 0, trailing: 0))

            ForEach(myList, id: \.self) { element in
                Text("Hi there")
            }
        }
    }
}

And I'm trying to remove the top line that I'm not even sure where it belongs to:

enter image description here

Any clue? I'm supporting from iOS 13.

Edit:

It seems to be part of the Cell:

enter image description here

1 Answers

Here we can use listStyle(), I found that concrete listStyle that system provide and also not having divider between row content is SidebarListStyle()).

Using this,

var body: some View {
    VStack {
            List {
                SearchBar(text: $searchText, placeholder: "Place Holder")
                    .background(Color.white)
                    .listRowInsets(.init(top: 0, leading: 0, bottom: 0, trailing: 0))

                ForEach(myList, id: \.self) { element in
                    Text("Hi there")
                    Divider()
                }
            }
            .listStyle(SidebarListStyle())
    }
}
Related