Lenny Magico
Lenny Magico

Reputation: 1203

Xcode fullscreen window without titlebar

I would like to create a full screen application (mac) but eventhough I have the window fullscreen; [window setFrame:[window frameRectForContentRect:[[window screen] frame]]display:YES animate:YES];

I can't get rid of the title bar? Can you change the above code to make the window without a titlebar or do you have to do it completely different? Thanks :)

Upvotes: 2

Views: 3624

Answers (2)

Daniel Vogelnest
Daniel Vogelnest

Reputation: 959

I successfully placed the window over the titlebar using the window level NSScreenSaverWindowLevel, instead of NSFloatingWindowLevel suggested in Macmade's answer.

fullscreenWindow = [[NSWindow alloc]
                    initWithContentRect:[[NSScreen mainScreen] frame]
                    styleMask:NSBorderlessWindowMask
                    backing:NSBackingStoreBuffered
                    defer:YES];
[fullscreenWindow setLevel:NSScreenSaverWindowLevel];
// Perform further configuration here, e.g. setTitle, setBackgroundColor etc.
[fullscreenWindow makeKeyAndOrderFront:nil];

Upvotes: 1

Macmade
Macmade

Reputation: 53970

CocoaWithLove has a good article about it:

http://cocoawithlove.com/2009/08/animating-window-to-fullscreen-on-mac.html

fullscreenWindow = [[FullscreenWindow alloc]
    initWithContentRect:[mainWindow contentRectForFrameRect:[mainWindow frame]]
    styleMask:NSBorderlessWindowMask
    backing:NSBackingStoreBuffered
    defer:YES
    screen:[mainWindow screen]];
[fullscreenWindow setLevel:NSFloatingWindowLevel];
[fullscreenWindow setContentView:[mainWindow contentView]];
[fullscreenWindow setTitle:[mainWindow title]];
[fullscreenWindow makeKeyAndOrderFront:nil];

Upvotes: 4

Related Questions