Reputation: 8586
I am developing an app for Mac OSX in Xcode5
and I want to display my first Window in fullscreen (no toolbar just my view)
I found a way to display a button on the corner for fullscreen:
AppDelegate.m:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
screenFrame = [[NSScreen mainScreen] frame];
[self.window setBackgroundColor: NSColor.whiteColor];
[self.window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
[[self window] setFrame:screenFrame display:YES];
}
but to get fullscreen I have to click on the corner's button
how to get fullscreen saving the step of pressing that button?
Upvotes: 5
Views: 7371
Reputation: 119
Swift Version:
let screenFrame = NSScreen.main?.frame
self.window?.collectionBehavior = NSWindow.CollectionBehavior.fullScreenPrimary
self.window?.setFrame(screenFrame!, display: true)
self.window?.toggleFullScreen(self)
Upvotes: 5
Reputation: 2791
add this [self.window toggleFullScreen:self];
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
screenFrame = [[NSScreen mainScreen] frame];
[self.window setBackgroundColor: NSColor.whiteColor];
[self.window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
[self.window setFrame:screenFrame display:YES];
[self.window toggleFullScreen:self];
}
Upvotes: 11