VStack
如果您的目标是在标头 +内容周围添加边框,那么您可以尝试使用一个容器来为
struct ContentView: View {
var body: some View {
ScrollView {
LazyVStack(pinnedViews: [.sectionHeaders]) {
Section {
Text("Content")
} header: {
Text("Header")
}
.padding()
.overlay {
RoundedRectangle(cornerRadius: 12)
.stroke(.blue, lineWidth: 1)
}
}
}
}
}
中的内容使用一个容器。然后:
使用
Section
测量容器的滚动偏移
.onGeometryChange