How to make your app open in full screen on Lion

One of Lions new features is full screen apps. Full screening an app is supposed to remove all distractions and make room for more of the app’s UI. Actually implementing this in your app is quite simple, but finding how to do it online can be a bit tricky.

There are two ways to do it, one is with NSApplication and the other is with NSWindow.

To do it with NSApplication, you’ll make this simple call

   [[NSApplication sharedApplication]
           setPresentationOptions:NSFullScreenWindowMask];

To do it with NSWindow you’ll make this one

   [window setCollectionBehavior:
             NSWindowCollectionBehaviorFullScreenPrimary];

There is also an NSWindowCollectionBehaviorFullScreenAuxiliary that you can use to allow auxiliary windows to show up in the space with the main window.

Calling either of these methods will add the resize button to the upper right corner of the window. You can call them at any time also. If you want it to be in the app all the time, call it somewhere like applicationDidFinishLaunching.

One thing to remember is that fullscreen functionality like this is LION ONLY. If you’re using this in an app that targets more than 10.7, make sure to do the appropriate checks around this code.

This entry was posted in Uncategorized and tagged , , , , . Bookmark the permalink.

2 Responses to How to make your app open in full screen on Lion

  1. James M says:

    Hi,

    Do you know if there is a way to make the app open in full screen on launch? This adds the button, but I am looking to make the app fullscreen without needing to push the button.

    Thanks :)

  2. Haris Amin says:

    Hey James,

    I came across this issue, just call this in applicationDidFinishLaunching


    [window toggleFullScreen];

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>