我一直在尝试使用GroupedListStyle()
来减少列表中各节之间的间隔,但没有任何运气。
上图中的代码:
struct ContentView: View {
var body: some View {
List(){
Section(){
Text("Hello, World!")
Text("Hello, World!")
Text("Hello, World!")
}
Section(){
Text("Hello, World!")
}
Section(){
Text("Hello, World!")
Text("Hello, World!")
}
}.listStyle(GroupedListStyle())
}
}
任何建议将不胜感激。
答案 0 :(得分:0)
我不喜欢这个解决方案,但我回想起 UITableView
的工作原理,并猜测可能是页脚间距导致了这种情况。
我补充说:
UITableView.appearance().sectionFooterHeight = 0
到视图的初始化,这似乎奏效了。
我知道这会全局设置该外观,因此在视图消失时重置该值可能会很好。
答案 1 :(得分:0)
您可以像这样将其添加到视图之外
struct ContentView: View {
init() {
UITableView.appearance().sectionFooterHeight = 0
}
var body: some View {}
}