Combine NavigationTitle and Navigation Back Button SwiftUI

1.3k views Asked by At

I have an app that has a navigationLink from one view to another, but when the NavLink moves to the second view, the NavigationTitle of that view is pushed, down, it's not inline. Is there any way to combine the toolbar and the title? I put my code below.

import SwiftUI

struct FirstView: View {
    var body: some View {
        NavigationView {
            Text("My Stuff")
                .toolbar {
                    ToolbarItem(placement: .navigationBarTrailing){
                        NavigationLink(destination: SettingsView(), label: {
                            Image(systemName: "gear")
                                .font(.system(size: 25))
                                .navigationTitle("My Stuff")
                        })
                        
                        
                      
                    }
                    
                    
            }
        }
    }
}

And the second view:

import SwiftUI

struct SettingsView: View {
    
    var body: some View {
        NavigationView {
            VStack {
                Text("Settings View")
                    .navigationTitle("Settings")
                
            }
        }
    }
}

A photo below of what is happening:photo of problem

Thank you for your help.

1

There are 1 answers

0
AudioBubble On BEST ANSWER

jnpdx solved this... the solution was that I had an extra NavigationView in my SettingsView. I only needed one NavigationView.