How can I disable the close button?

Also try;

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

etc.


In Xcode 9.1 you can use following in the ViewController,

override func viewWillAppear() {

    self.view.window?.titleVisibility = .hidden
    self.view.window?.titlebarAppearsTransparent = true

    self.view.window?.styleMask.insert(.fullSizeContentView)

    self.view.window?.styleMask.remove(.closable)
    self.view.window?.styleMask.remove(.fullScreen)
    self.view.window?.styleMask.remove(.miniaturizable)
    self.view.window?.styleMask.remove(.resizable)

    //self.view.window?.isMovable = false
}

enter image description here

override func viewWillAppear() {

    self.view.window?.titleVisibility = .hidden
    self.view.window?.titlebarAppearsTransparent = true

    self.view.window?.styleMask.insert(.fullSizeContentView)

    //self.view.window?.styleMask.remove(.closable)
    self.view.window?.styleMask.remove(.fullScreen)
    self.view.window?.styleMask.remove(.miniaturizable)
    self.view.window?.styleMask.remove(.resizable)

    //self.view.window?.isMovable = false
}

enter image description here

Tags:

Macos

Cocoa

Swift