I have this code to display a list of custom rows.
struct ContentView : View {
var body: some View {
VStack(alignment: .leading) {
List(1...10) {_ in
CustomRow()
}
}
}
}
However, I want to remove the line on each row. I tried not using List
and instead using ForEach
inside ScrollView
but it completely removes all the styling including its padding and margins. I just want to remove the lines and nothing else.
Please help, thank you.
Best Answer
iOS 15:
This year Apple introduced a new modifier
.listRowSeparator
that can be used to style the separators. you can pass.hidden
to hide it:iOS 14:
you may consider using a
LazyVStack
inside aScrollView
instead (because iOS is NOT supporting appearance for SwiftUI lists anymore).iOS 13:
There is a
UITableView
behind SwiftUI'sList
for iOS 13. So to removeExtra separators (below the list):
you need a
tableFooterView
and to removeAll separators (including the actual ones):
you need
separatorStyle
to be.none
Example of usage
Note that a static list doesn't show extra separators below the list by default