我想创建一个全屏应用程序(mac)但是尽管我有全屏窗口;
[window setFrame:[window frameRectForContentRect:[[window screen] frame]]display:YES animate:YES];
我无法摆脱标题栏?您是否可以更改上面的代码以使窗口没有标题栏,或者您是否必须完全不同?谢谢:))
答案 0 :(得分:4)
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];
答案 1 :(得分:1)
我使用窗口级NSScreenSaverWindowLevel
成功地将窗口放在标题栏上,而不是Macmade的答案中建议的NSFloatingWindowLevel
。
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];