NSWindow全屏,但显示停靠

时间:2011-05-27 09:43:45

标签: objective-c xcode window fullscreen dock

现在我终于通过http://cocoadevcentral.com/articles/000028.php设法创建了一个全屏窗口 精彩的教程。现在的问题是如何使用以下代码来显示dock和菜单栏,因为目前我有一个完全黑屏,我想看到一个菜单栏和一个底座。这可能吗?

- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
     int windowLevel;
     NSRect screenRect;
     // Capture the main display
     if (CGDisplayCapture( kCGDirectMainDisplay ) != kCGErrorSuccess) {
         NSLog( @"Couldn't capture the main display!" );
         // Note: you'll probably want to display a proper error dialog here
     }
     // Get the shielding window level
     windowLevel = CGShieldingWindowLevel();
     // Get the screen rect of our main display
     screenRect = [[NSScreen mainScreen] frame];
     // Put up a new window
     mainWindow = [[NSWindow alloc] initWithContentRect:screenRect
                                    styleMask:NSBorderlessWindowMask
                                    backing:NSBackingStoreBuffered
                                    defer:NO screen:[NSScreen mainScreen]];
     [mainWindow setLevel:windowLevel];
     [mainWindow setBackgroundColor:[NSColor blackColor]];
     [mainWindow makeKeyAndOrderFront:nil];
     // Load our content view
     [slideShowPanel setFrame:screenRect display:YES];
     [mainWindow setContentView:[slideShowPanel contentView]];
}

1 个答案:

答案 0 :(得分:1)

进行了一些实验,但我发现了;

- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
int windowLevel;
NSRect screenRect;
// Capture the main display

// Get the screen rect of our main display
screenRect = [[NSScreen mainScreen] frame];
// Put up a new window
mainWindow = [[NSWindow alloc] initWithContentRect:screenRect
                                         styleMask:NSBorderlessWindowMask
                                           backing:NSBackingStoreBuffered
                                             defer:NO screen:[NSScreen mainScreen]];
[mainWindow setLevel:windowLevel];
[mainWindow setBackgroundColor:[NSColor blackColor]];
[mainWindow makeKeyAndOrderFront:nil];
// Load our content view
[slideShowPanel setFrame:screenRect display:YES];
[mainWindow setContentView:[slideShowPanel contentView]];

}