Hi, I would like to add a topbar in the panel in VisionOS by using ToolbarTitleMenu, reffering to the document: https://developer.apple.com/documentation/swiftui/toolbartitlemenu, but in the simulator, I cannot see the topbar, what's wrong with my code?
Hey @YimingLi,
Great question. The ToolbarTitleMenu
requires a navigation view (like NavigationStack
) and a navigationTitle
. Please update your code to be similar to the following:
NavigationStack {
Text("Hello World")
.navigationTitle("My Project")
.toolbar {
ToolbarTitleMenu {
Button("New", systemImage: "pencil") {}
}
}
}
Let me know if you have more questions,
Michael