我有以下代码:
NSRect contentRect = NSZeroRect;
contentRect.size = NSMakeSize(400, 400);
contentRect.origin = NSMakePoint(400, 400);
NSWindow* window = [[NSWindow alloc] initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
[window setBackgroundColor:[NSColor blackColor]];
[window setMovableByWindowBackground:NO];
[window setExcludedFromWindowsMenu:YES];
[window setAlphaValue:0.8];
[window setOpaque:NO];
[window setHasShadow:YES];
[window useOptimizedDrawing:YES];
[NSApp activateIgnoringOtherApps:YES];
[window makeKeyAndOrderFront:nil];
它被- (BOOL) applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
. 单击 Dock 图标时会调用此函数。
为什么我的窗口不显示?
我还注意到,在停靠图标上单击十几次时。有时我看到我的窗口每秒出现 1/10。然后它消失了。