Sor*_*ica 14 ios swift swiftui
我想消除第Section一个上方的空间Form
var body: some View {
VStack {
Text("Text 1")
Form {
Section {
Text("Text 2")
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我试图将 Section 的 header 的 frame 设置为 0,但它不起作用
解决方案是使用 aSection和 anEmptyView()并将您想要的视图放在此标题的顶部Section
var body: some View {
VStack {
Text("Text 1")
Form {
Section(header: VStack(alignment: .center, spacing: 0) {
Text("Text 2").padding(.all, 16)
.frame(width: UIScreen.main.bounds.width, alignment: .leading)
.background(Color.white)
}) {
EmptyView()
}.padding([.top], -6)
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6525 次 |
| 最近记录: |