现在我尝试过
NavigationView {
Form {
Section {
Text("Error message!")
}.background(Color.red.opacity(0.2))
Section {
Text("Label 1")
}
Section {
Text("Label 2")
}
}.navigationBarTitle("title", displayMode: NavigationBarItem.TitleDisplayMode.inline)
}
Run Code Online (Sandbox Code Playgroud)
但是,似乎有一个预定义的填充,所以我无法填充边距
也许这会有所帮助,至少在模拟器中这似乎是您请求的解决方案:
NavigationView {
Form {
Section {
HStack {
Text("Error message!")
Spacer()
}
.padding(.vertical)
.listRowInsets(EdgeInsets())
}
.padding(.horizontal)
.background(Color.red.opacity(0.2))
Section {
Text("Label 1")
}
Section {
Text("Label 2")
}
}
.navigationBarTitle("title", displayMode: .inline)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5531 次 |
| 最近记录: |