How do I add an image to in the corner of the navigationbar, keeping the title in the center?
something like this -
CodePudding user response:
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)
}
}
}
}
}