Reputation: 2035
I have a NavigationView and added a title. 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
Upvotes: 4
Views: 1766
Reputation: 7708
You have a double-nested 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.
This is because the navigation view context is preserved when you use a NavigationLink
.
Try removing it:
var body: some View {
Form {
Section {
Text("Hello World")
}
}
.navigationBarTitle("SwiftUI", displayMode: .inline)
}
Upvotes: 9