我想创建一个全屏应用程序(mac),但即使我有全屏窗口;
[window setFrame:[window frameRectForContentRect:[[window screen] frame]]display:YES animate:YES];
我无法摆脱标题栏?您可以更改上面的代码以使窗口没有标题栏,还是必须完全不同?谢谢 :)
我想创建一个全屏应用程序(mac),但即使我有全屏窗口;
[window setFrame:[window frameRectForContentRect:[[window screen] frame]]display:YES animate:YES];
我无法摆脱标题栏?您可以更改上面的代码以使窗口没有标题栏,还是必须完全不同?谢谢 :)
CocoaWithLove 有一篇关于它的好文章:
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];
我使用 window level 成功地将窗口放置在标题栏上NSScreenSaverWindowLevel
,而不是NSFloatingWindowLevel
在 Macmade 的回答中建议。
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];