views:

695

answers:

5

Is there a way to hide the titlebar in an NSWindow? I don't want to have to completely write a new custom window. I can't use NSBorderlessWindowMask because I have a bottom bar on my window, and using NSBorderlessWindowMask makes that disappear. I also tried using setContentBorderThickness:forEdge: with NSMaxYEdge and setting it to 0, that didn't work either.

Any help is appreciated

+1  A: 

Make a custom window. It's not hard to do.

NSResponder
A: 

What happens if you get the superview of the close button? Can you hide that?

// Imagine that 'self' is the NSWindow derived class
NSButton *miniaturizeButton = [self standardWindowButton:NSWindowMiniaturizeButton];
NSView* titleBarView = [miniaturizeButton superview];
[titleBarView setHidden:YES];
Lyndsey Ferguson
I tried this and it just turns the window white and blank. If I'm not mistaken, the superview of the button is NSThemeFrame. However, I might try adjusting the frame of the view to see if I can shrink it.
macatomy
Adjusting the frame doesn't work well, I get all sorts of strange results. Pretty much stuck I suppose.
macatomy
The reason that didn't work is that the NSThemeFrame is the superview of the window's contentView. Hide the frame view, and all its subviews get hidden, too.
NSResponder
Just for fun I class dumped NSThemeFrame's header and other related classes then found some private methods in there for returning the titlebar height. Then I loaded my custom theme frame subclass in my NSWindow subclass and tried it, and it did work, but it got rid of my rounded corners and the bottom bar as well. Oh well.
macatomy
A: 

[yourWindow setStyleMask:NSBorderlessWindowMask];

+1  A: 

The only way I know would be to create a window without a titlebar (see NSBorderlessWindowMask). Note that you can't (easily) create a window without a titlebar in IB, so you will have to do a bit of work in code (there are a couple of different approaches, you can probably figure it out).

A big drawback with using a window without a titlebar is that you're now on the hook for much more of the standard appearance and behaviour - rounded corners and such.

Kukoda János
+1  A: 

I pretty much just ended up changing the design of my app so that this isn't necessary, for all those who are thinking about doing the same, its not a great way to go.

macatomy