I am trying to make a NavigationView in SwiftUI that has a logo centered and a button right justified.
Here is what I have tried with no success. I cannot figure out how to remove the title and replace it with a image logo.
.navigationBarTitle("", displayMode: .inline)
.navigationBarItems(trailing: Button(action: {
}) {
Image("mylogo")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 154, height: 42)
Button(action: {
// Actions
}, label: { Image("hamburger_menu")
.resizable()
.frame(width: 24, height: 24)
})
})
And this:
.toolbar {
ToolbarItem(placement: .navigation) {
HStack {
Image("mylogo")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 154, height: 42, alignment: .center)
Image("hamburger_menu")
.resizable()
.frame(width: 48, height: 48, alignment: .trailing)
}
}
}
It works ok with text as seen here:
.navigationBarTitle("Text", displayMode: .inline)
.navigationBarItems(trailing: Button(action: {
} ) {
Image("hamburger_menu")
.resizable()
.frame(width: 24, height: 24)
} )