我似乎无法摆脱 ScrollView 顶部的 ~6 高度填充(?)。我尝试在 ScrollView 本身及其内容上将填充设置为 0。我尝试使用 SwiftUI-Introspect 来获取内容插图,但它们似乎已经为顶部的 0。我可以只使用偏移量(y:-6),但我想了解导致填充的原因。有人知道吗?
var body: some View {
VStack(spacing: 0) {
Rectangle()
.frame(width: UIScreen.main.bounds.width, height: 200)
.foregroundColor(.blue)
Rectangle()
.frame(width: UIScreen.main.bounds.width, height: 200)
.foregroundColor(.red)
ScrollView {
Rectangle()
.frame(width: UIScreen.main.bounds.width, height: 200)
.foregroundColor(.black)
}
}
}