-3

How do I add an image to in the corner of the navigationbar, keeping the title in the center?

something like this -

enter image description here

Aviram Netanel
  • 12,633
  • 9
  • 45
  • 69
  • Formally it duplicates https://stackoverflow.com/questions/56546213/how-to-put-a-logo-in-navigationview-in-swiftui – Asperi Aug 07 '22 at 18:17
  • @Asperi I think it's better defined and moreover - it shows adding an image IN ADDITION to the title, and not just instead of it. – Aviram Netanel Aug 07 '22 at 22:21

1 Answers1

0

here is the code:

struct ContentView: View {
var body: some View {
            
    NavigationView{
        
        Text("Hello")

        .navigationBarTitleDisplayMode(.inline)
                .toolbar {
                    ToolbarItem(placement: .principal) {
                            Text("Title")
                                .font(.title)
                    }
                    
                    ToolbarItem(placement: .navigationBarTrailing) {
                            Image(Constants.logoImage).resizable()
                                .scaledToFit()
                                .frame(width: 100, height: 50, alignment: .trailing)
                        }
                    }
    }
}
}
Aviram Netanel
  • 12,633
  • 9
  • 45
  • 69