I'm working on a little mac app where I want a pretty specific style for the window. I want to remove the application's menu bar completely, and then go about adding a custom close button. (Just a little white 'X' with no borders.) The reason I want this is I'm looking to make the application's background image cover the entire window, not just the view controller area and a gray title bar splotched above. So far, my window controller contains this:
self.window!.titleVisibility = NSWindowTitleVisibility.Hidden;
self.window!.titlebarAppearsTransparent = true
self.window!.movableByWindowBackground = true
All this does is remove the gray bar, but the buttons are left just where they were.
Thanks for reading, all help is appreciated.
To show/hide window buttons would want to set the visibility of NSWindowButton
:
These constants provide a way to access standard title bar buttons:
enum NSWindowButton : UInt {
case CloseButton
case MiniaturizeButton
case ZoomButton
case ToolbarButton
case DocumentIconButton
case DocumentVersionsButton
case FullScreenButton
}
So you would likely use something such as this to set this visibility:
self.window!.standardWindowButton(NSWindowButton.CloseButton)?.hidden = true
Any other constants you want to prevail would likely work the same way. You would then set your new custom close button for example to the applications first responder terminate
function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With