Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NavigationView height irregular swiftui

Tags:

swift

swiftui

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

enter image description here

like image 860
King Avatar asked Sep 16 '25 21:09

King


1 Answers

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) 
}
like image 128
Bradley Mackey Avatar answered Sep 19 '25 22:09

Bradley Mackey