1
现在我终于设法通过http://cocoadevcentral.com/articles/000028.php 创建一个全屏窗口辉煌的教程。现在问题如何使用下面的代码来显示码头和菜单栏,因为目前我有一个完全黑屏,我想看到一个菜单栏和一个码头。那可能吗?NSWindow全屏显示,但显示码头
- (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]];
}
我diff'ed这些,这是一个很大的区别...你在哪里获得了能够显示码头+菜单栏的功能?我不能得到它的工作... – 2011-11-19 19:46:27
windowLevel被使用前未初始化。我猜它随机创建了适当的值,将窗口级别设置为高于所有其他窗口,但低于CGShieldingWindowLevel()返回的值。我会极力鼓励以适当的方式来做到这一点,比如windowLevel = CGShieldingWindowLevel() - 1; – ekscrypto 2012-06-03 19:02:02