I am trying to make my app have more 'flat' feel so I think it is a good idea to hide the title bar.
However, in reality titlebarAppearsTransparent
seems only remove the title bar shadow but not make the title bar truly transparent.
Before using any code to modify the title bar,
After adding the following code (starting have a better feel),
self.window?.titlebarAppearsTransparent = true
Setting the background color to white,
self.window?.backgroundColor = NSColor.whiteColor()
self.window?.titlebarAppearsTransparent = true
This is certainly not what I want. I thought I just turned the title bar transparent to true
. What is going on here?
Any hint or comment is appreciated and thanks for your time viewing this question.
Try add:
self.window?.styleMask |= NSFullSizeContentViewWindowMask
When set, the content view consumes the full size of the window; it can be combined with other window style masks, but is only respected for windows with a title bar. Using this mask opts in to layer backing. Use the contentLayoutRect or contentLayoutGuide to lay out views underneath the title bar-toolbar area
If you don't want to keep the title bar at all, you can also added:
self.window?.titleVisibility = NSWindowTitleVisibility.Hidden;
The window hides the title and moves the toolbar up into the area previously occupied by the title.
You might also wanted to add this in order to move the window by dragging its content view:
self.window?.movableByWindowBackground = YES
A Boolean value that indicates whether the window is movable by clicking and dragging anywhere in its background. The value of this property is YES when the window is movable by clicking and dragging anywhere in its background; otherwise, NO.
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