【发布时间】:2021-09-06 14:55:46
【问题描述】:
我在 Stack Overflow 上看到过类似的问题,但没有一个能够回答我的问题。
我创建了一个List,但我想删除List 中内容上方的填充空间(用红色箭头标记)。使用GroupedListStyle时如何删除它?
这是通过fullscreenCover 显示的NavigationView 中的VStack 中的List:
var body: some View {
NavigationView {
VStack {
taskEventPicker
myList
}
.navigationBarTitle("Add Task", displayMode: .inline)
}
}
其中taskEventPicker 是分段的Picker(绿色框内):
var modePicker: some View {
Picker("Mode", selection: $selection) { /* ... */ }
.pickerStyle(SegmentedPickerStyle())
.padding()
}
myList 是有问题的表格(黄色框内):
var myList: some View {
List { /* ... */ }
.listStyle(GroupedListStyle())
}
我的尝试
- Removing the header of the list
- Hiding the Navigation Bar title
- Setting
UITableView.appearance().tableHeaderViewto an empty frame - Attempting
UITableView.appearance().contentInset.top = -35 -
Setting
listRowInsets(这会影响所有列表行)
注意:我正在寻找适用于GroupedListStyle 的答案。我了解PlainListStyle 不会出现此问题。默认listStyle 也会出现此填充问题。
感谢您的帮助!
Xcode 版本:12.5
【问题讨论】:
标签: ios swift swiftui swiftui-list