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")
}
Result:
I've tried embedding the List inside a VStack
and adding Spacer()
like below code but it's not working properly. It removes about half of the empty cells.
VStack{
List {
Text("Item 1")
Text("Item 2")
Text("Item 3")
}
Spacer()
}
How would I remove these extra separators in SwiftUI?
Best Answer
iOS 14:
iOS 14 doesn't show extra separators below the list by default and to removing all separators, you need to use a
LazyVStack
inside aScrollView
instead. (because iOS is NOT supporting appearance for SwiftUI lists anymore).iOS 13:
No need for
Section
or.grouped
style!There is a
UITableView
behind SwiftUI'sList
for iOS 13. So to remove- Extra separators (below the list):
you need a
tableFooterView
and to remove. Note that iOS 14 doesn't show extra separators below the list by default.- All separators (including the actual ones):
you need
separatorStyle
to be.none
Note that it eliminates all tables/lists's separators. So you can toggle it in a methods like
onAppear()
or etc. as you wish.