Tzar
Tzar

Reputation: 4789

Unremovable Empty “View” Menu Bar Container

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:

Empty View menu still visible

Upvotes: 0

Views: 75

Answers (0)

Related Questions