Display os x window full screen on secondary monitor using Cocoa

后端 未结 3 1425
天涯浪人
天涯浪人 2020-12-05 05:49

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 seco

3条回答
  •  时光说笑
    2020-12-05 06:34

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

    Create a full screen window with:

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

    You might want to google CGDisplayCapture() as well.

提交回复
热议问题