gpt4 book ai didi

swift - 如何在 SwiftUI 中删除 List 和 ScrollView 的底部填充

转载 作者:行者123 更新时间:2023-12-05 02:04:50 33 4
gpt4 key购买 nike

我想删除底部填充,红色空间之间的白色空间。有什么办法可以实现吗?

enter image description here

测试代码:

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)
}
}
}

最佳答案

您必须传递 0 才能没有间距。默认情况下,它根据上下文使用默认空间

VStack(spacing: 0) {

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

.........
}

关于swift - 如何在 SwiftUI 中删除 List 和 ScrollView 的底部填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64022802/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com