customized Navigation bar

Hello all,

Im trying to add a back.chevron to the attached section of code above the navigationBartitle without the previous title included within the back button.

any ideas ?

Thankyou

Connor

import SwiftUI struct ContentView: View { init() { // Customize the UINavigationBar appearance let appearance = UINavigationBarAppearance() appearance.titleTextAttributes = [.font : UIFont.systemFont(ofSize: 35)] // Increase title font size //appearance.largeTitleTextAttributes = [.font : UIFont.systemFont(ofSize: 35)] // Increase large title font size UINavigationBar.appearance().standardAppearance = appearance } @EnvironmentObject var appData: AppData

var body: some View {
    NavigationStack(path: $appData.path) {
        HStack {
            Spacer() // Push the title to the center
            VStack {
                
                NavigationLink(value: 1) {
                    Circle()
                        .frame(width: 100, height: 100)
                }
                
                NavigationLink(value: 2) {
                    Circle()
                        .frame(width: 100, height: 100)
                }
                
                NavigationLink(value: 3) {
                    Circle()
                        .frame(width: 100, height: 100)
                }

            }
            
            .navigationDestination(for: Int.self) { value in
                if  value == 1 {
                    TestView1()
                }
                else {
                    Text("Selected box: \(value)")
                }
            }
            Spacer() // Push the content to the right
        }
         .navigationBarTitle("Todo Lists", displayMode: .inline)
               
        //this section updates "path as you click though the navigation,links"
        
        .onReceive(appData.$path) { CurrentSelectionCode in
            let path = CurrentSelectionCode
            print("your path is:", path)
                
        }
    }
}

}

struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }

Accepted Answer

There is a solution that dips into UIKit which will set the navigation bar's back button to display only the indicator image (chevron) without the title.

// Requires iOS 14.0+
extension UINavigationController {
    open override func viewWillLayoutSubviews() {
        super.viewWillLayoutSubviews()
        navigationBar.topItem?.backButtonDisplayMode = .minimal
    }
}

Note, however, that this will remove the title from every back button in your app.

Thankyou BabyJ!

customized Navigation bar
 
 
Q