Home > AI > IOS > SwiftUI >

(navigation)custom title

struct ContentView: View {
    var body: some View {
        NavigationView {
            Text("ContentView")
                .navigationBarTitleDisplayMode(.inline)
                .navigationBarItems(leading: Text("back"), trailing: Text("forward"))
                .toolbar {
                    ToolbarItem(placement: .principal) { 
                        CustomTitleView()
                    }
                }
        }
    }
}


struct CustomTitleView: View {
    var body: some View {
        HStack {
            Image(systemName: "pencil")
            Text("good")
                .font(.headline)
        }
    }
}
Relevant tags:

Leave a Reply