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?
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];
}
Swift Version:
let screenFrame = NSScreen.main?.frame
self.window?.collectionBehavior = NSWindow.CollectionBehavior.fullScreenPrimary
self.window?.setFrame(screenFrame!, display: true)
self.window?.toggleFullScreen(self)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With