Search code examples
cocoafullscreentitlebar

Hide title bar on a custom window


I am using:

toggleFullScreen:

With a custom window:

self = [super initWithContentRect:contentRect styleMask:NSResizableWindowMask backing:bufferingType defer:flag];

And i have created a custom title bar from an NSView. When i go to fullscreen everything goes well except that obviously the custom title bar is still visible. Is there any way to define a fullscreen rect or something so that when i go full screen the title bar is not visible?


Solution

  • You need to register an object as the window's delegate and then implement one or more of the full-screen-related delegate methods:

    - (void)windowWillEnterFullScreen:(NSNotification *)notification;
    - (void)windowDidEnterFullScreen:(NSNotification *)notification;
    - (void)windowWillExitFullScreen:(NSNotification *)notification;
    - (void)windowDidExitFullScreen:(NSNotification *)notification;
    

    In your implementation you should remove your custom title bar from the window, and then add it back when the window exits full screen mode.

    There is a lot more information about full screen mode in the Lion Application Kit Release Notes.