如何在SwiftUI中删除列表和滚动视图的底部填充

如何在SwiftUI中删除列表和滚动视图的底部填充,swift,swiftui,swiftui-list,Swift,Swiftui,Swiftui List,我想去掉底部填充物,红色区域之间的空白区域。有什么办法可以实现吗 测试代码: struct ContentView: View { var body: some View { return NavigationView { VStack { // the same result with using List instead of ScrollView ScrollView {

我想去掉底部填充物,红色区域之间的空白区域。有什么办法可以实现吗

测试代码:

struct ContentView: View {
    var body: some View {
        return NavigationView {
            VStack {
                // the same result with using List instead of ScrollView
                ScrollView {
                    ForEach(1..<100) { index in
                        HStack {
                            Spacer()
                            Text("\(index)")
                            Spacer()
                        }
                    }
                }.background(Color.red)
                HStack {
                    Spacer()
                    Text("Test")
                    Spacer()
                }
                .background(Color.red)
            }
            .navigationBarTitle(Text("Test"), displayMode: .inline)
        }
    }
}
struct ContentView:View{
var body:一些观点{
返回导航视图{
VStack{
//使用列表而不是滚动视图的结果相同
滚动视图{

ForEach(1..您必须传递
0
以不使用空格。默认情况下,它根据上下文使用默认空格

VStack(spacing: 0) {

   // the same result with using List instead of ScrollView
   ScrollView {

   .........
}

您必须通过
0
才能不使用空格。默认情况下,它会根据上下文使用默认空格

VStack(spacing: 0) {

   // the same result with using List instead of ScrollView
   ScrollView {

   .........
}

我尝试了这个,但事实并非如此?列表视图的底部和下一个视图之间仍然存在差距,无论它是否嵌入到间距为0的VStack中。请参见此处,因为我正在尝试解决类似问题。我尝试了这个,但事实并非如此?列表视图的底部和下一个视图之间仍然存在差距无论它是否嵌入到间距为0的VStack中。请看这里,因为我正在尝试解决类似的问题。