Search code examples
swiftmacoscocoa

How can I disable the close button?


I need some help with figuring out how to disable/hide the close, minimize, and resize buttons in OS X Cocoa and Swift 2. Here's the code I tried. I know it's for the Title Bar, but I thought I'd try it anyway:

self.window.titleVisibility = NSWindowTitleVisibility.Hidden;

Does any one know how to do that? I'm using Swift 2, OS X Cocoa, and Xcode 7.2. Thanks!


Solution

  • Also try;

        self.window!.standardWindowButton(NSWindow.ButtonType.closeButton)!.hidden = true
        self.window!.standardWindowButton(NSWindow.ButtonType.miniaturizeButton)!.hidden = true
    

    etc.