Search code examples
nswindownsmenumacos-sierra

How do I disable the Show Tab Bar menu option in Sierra apps?


I've got an app that uses a Toolbar in a NSWindow. I don't want users to be able to customize this toolbar for aesthetic reasons. In Sierra there's a new Menu option that gets inserted into "Menu > View" called Show Tab Bar. How do I disable this? Enabling it only seems to increase the tool bar's height as I don't have extra labels showing under the icons.


Solution

  • On 10.12, you need to now set the following when the window is created as Tab Bar is now available by default:

    [NSWindow setAllowsAutomaticWindowTabbing: NO];
    

    The answer is the same in Swift and SwiftUI

    func applicationWillFinishLaunching(_ notification: Notification) {
        NSWindow.allowsAutomaticWindowTabbing = false
    }
    

    Note that the call is made on the class NSWindow not on an instance of NSWindow