Xcode 全屏窗口没有标题栏

发布于 2024-10-26 03:03:46 字数 198 浏览 0 评论 0原文

我想创建一个全屏应用程序(mac),但即使我有全屏窗口; [window setFrame:[window frameRectForContentRect:[[window screen] frame]]display:YES animate:YES];

我无法摆脱标题栏?您可以更改上面的代码以使窗口没有标题栏还是必须完全不同?谢谢 :)

I would like to create a full screen application (mac) but eventhough I have the window fullscreen;
[window setFrame:[window frameRectForContentRect:[[window screen] frame]]display:YES animate:YES];

I can't get rid of the title bar? Can you change the above code to make the window without a titlebar or do you have to do it completely different? Thanks :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

套路撩心 2024-11-02 03:03:46

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];

CocoaWithLove has a good article about it:

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];
独夜无伴 2024-11-02 03:03:46

我使用窗口级别 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];

I successfully placed the window over the titlebar using the window level NSScreenSaverWindowLevel, instead of NSFloatingWindowLevel suggested in Macmade's answer.

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];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文