Reputation: 17787
On macOS with new SwiftUI framework without AppDelegate
/ SceneDelegate
, how do I hide the window title?
I found this article from Apple that describes how to do it for a Catalyst app but without that delegate now, how do I achieve this?
Link to article - https://developer.apple.com/documentation/uikit/mac_catalyst/removing_the_title_bar_in_your_mac_app_built_with_mac_catalyst
Upvotes: 8
Views: 2633
Reputation: 3487
The answers here are already good but after macOS 14 Sonoma we have a few more options for toolbars in navigation views which also use titles.
You can keep the toolbar visible but remove the title using .toolbar(removing: .title)
e.g.:
WindowGroup {
NavigationSplitView {
SidebarView()
} detail: {
ContentView()
}
.toolbar(removing: .title)
}
In addition to .title
there's also .sidebarToggle
.
There's also .toolbarBackgroundVisibility(.hidden, for: .windowToolbar)
, which you can use to show/hide the background of the toolbar in case you have a large image or something that should extend to the top of the screen.
This removes them from the interface but still keeps them available for accessibility and things like clicking 'Window' in the menu bar and seeing the window title.
See the WWDC24 video Tailor macOS windows with SwiftUI for more info.
Upvotes: 0
Reputation: 91
Now it's:
WindowGroup {
ContentView()
}
.windowStyle(.hiddenTitleBar)
Upvotes: 7
Reputation: 257493
You need to use the following window style:
WindowGroup {
ContentView()
}
.windowStyle(HiddenTitleBarWindowStyle())
Upvotes: 16