Home > Software engineering >  SwiftUI : How to get a Navigation Title aligned with Back Button
SwiftUI : How to get a Navigation Title aligned with Back Button

Time:09-18

I'm trying to get the navigation title vertically aligned with the back button in a NavigationDetail view in SwiftUI. Here's what this looks like currently:

enter image description here

Below's my code for adding the Navigation Bar title to the view. How do I get it vertically aligned with the Back button?

 var body: some View {
        Text("My Detail View")
            .navigationBarTitleDisplayMode(.inline)

        VStack {
            List {
                ForEach(0..<layerSettings.count, id: \.self) { each in
    ...
   }
}

CodePudding user response:

If you need to draw "My Detail View" on the same line that the Back button, try to do like this:

 NavigationView {
    VStack() {
       ...
    }
    .navigationBarTitle(Text("My Detail View"),
                        displayMode: .inline)
 }
  • Related