Reputation: 4789
In an app written in pure SwiftUI
, which doesn’t use tab bar, toolbar, or sidebar, with full-screen mode disabled, the system default View
top-level menu bar container remains visible even though it’s completely empty.
If the View
menu is empty, it should not be visible in the menu bar.
// App does not use sidebar nor toolbar
// Disable automatic window tabbing
NSWindow.allowsAutomaticWindowTabbing = false
// Disable zoom button
.onReceive(NotificationCenter.default.publisher(for: NSApplication.willUpdateNotification), perform: { _ in
if let window = NSApplication.shared.mainWindow {
window.standardWindowButton(.zoomButton)?.isEnabled = false
}
})
// Disable full-screen mode
.windowResizability(.contentSize)
// “View” menu in menu bar should now be empty
How can I disable or hide View
menu using only SwiftUI
?
Click to view the gif:
Upvotes: 0
Views: 75