Window without the top bar

How to have a window without the window bar? I mean without the bar, the title and the buttons on the top left.


I know that I can do that in the storyboard but I want to do it programmatically and with Swift


What I have tried:


override func viewWillAppear() {

super.viewWillAppear()


// view.window?.titlebarAppearsTransparent = true // It makes the bar transparent but I still see the buttons

}

Replies

You do this by setting the mask.


https://developer.apple.com/documentation/appkit/nswindowstylemask?language=objc

In interface Builder, in the attributes inspector, set the window by disabling:

- title bar

- Close

- Minimize

- Resize

Thank you Claude31 I mean programmatically. Sorry, my fault. I have updated my question

hi,


if you want to make changes in code, consider tweaking the styleMask when you create a window. check the documentation in NSWindow for


init(contentRect: NSRect, styleMask style: NSWindow.StyleMask, backing backingStoreType: NSWindow.BackingStoreType, defer flag: Bool)


the NSWindow.StyleMask struct then gives you access to the parameters you want, such as titled, closable, miniaturizable, resizable, and so on. however, it appears you can only do this when defining the window; i don't see right away that you can change them on an exisiting window.


hope that helps,

DMG