[英]NavigationView height irregular swiftui
I have a NavigationView and added a title.我有一个 NavigationView 并添加了一个标题。 The problem is it looks weird when I run it.
问题是当我运行它时它看起来很奇怪。
var body: some View {
NavigationView {
Form {
Section {
Text("Hello World")
}
}
.navigationBarTitle("SwiftUI", displayMode: .inline)
}
}
The image looks weird.图像看起来很奇怪。 How can I make the navigation height look better just like UIKIt Navigation Bar
如何让导航高度看起来更好,就像 UIKIt Navigation Bar 一样
You have a double-nested NavigationView
.您有一个双重嵌套的
NavigationView
。 The view that you are showing in your example is already being presented from a NavigationView
, so you don't need to create an additional view.您在示例中显示的视图已经从
NavigationView
呈现,因此您无需创建额外的视图。 This is because the navigation view context is preserved when you use a NavigationLink
.这是因为在使用
NavigationLink
时会保留导航视图上下文。
Try removing it:尝试删除它:
var body: some View {
Form {
Section {
Text("Hello World")
}
}
.navigationBarTitle("SwiftUI", displayMode: .inline)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.