使用 Cocoa 在辅助监视器上全屏显示 macOS 窗口 [英] Display macOS window full screen on secondary monitor using Cocoa

查看:21
本文介绍了使用 Cocoa 在辅助监视器上全屏显示 macOS 窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发 Cocoa Mac 应用程序,我需要在辅助监视器上全屏显示窗口/视图.

I'm working on a Cocoa Mac app where I need to display a window/view on a secondary monitor, full-screen.

我知道如何创建可以拖到辅助显示器上的窗口,但我想以编程方式创建窗口并使其在外部显示器上全屏显示.

I know how to create a window that could be dragged onto the secondary monitor, but I was wanting to programmatically create the window and make it full screen on the external monitor.

推荐答案

首先,通过迭代[NSScreen screen]来确定你想要使用哪个屏幕.

First, determine which screen you want to use by iterating over [NSScreen screens].

创建一个全屏窗口:

NSScreen *screen = /* from [NSScreen screens] */
NSRect screenRect = [screen frame];
NSWindow *window = [[NSWindow alloc] initWithContentRect:screenRect
    styleMask:NSBorderlessWindowMask
    backing:NSBackingStoreBuffered
    defer:NO
    screen:screen];
[window setLevel: CGShieldingWindowLevel()];

你可能还想用谷歌搜索 CGDisplayCapture().

You might want to google CGDisplayCapture() as well.

这篇关于使用 Cocoa 在辅助监视器上全屏显示 macOS 窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆