I can confirm this is also problem when having the toolbar item in .principal location when the view is first in hierarchy.
Subsequent views display the title properly.
NavigationView {
Text("Content")
.toolbar {
ToolbarItem(placement: .principal) {
Text("Title")
}
}
}
NavigationStack works as expected. Adding .navigationViewStyle(.stack) does not.
Post
Replies
Boosts
Views
Activity
Thanks to the above comment I experimented a bit more and I was able to fix it without using disabled button (as the button changes the opacity of the view when disabled)
The problem seems to be with the width calculation of the text - in my case specifying .frame(width: 200) on the Text in ToolbarItem renders the width properly:
NavigationView {
Text("Content")
.toolbar {
ToolbarItem(placement: .principal) {
Text("Title").frame(width: 200)
}
}
}