Why doesn't my NSPanel have a gray background, as usual?

My application has an icon in the menu bar. A NSPanel appears when I click the icon. But why NSPanel n't the NSPanel have a background color like another with a gray NSWindow background? My NSPanel background looks transparent. My NSPanel comes from a .xib file. My code is as follows:

 (void)openPanel { NSLog(@"openPanel"); NSWindow *panel = self.panelController.window; NSRect rect = [[[NSApp currentEvent] window] frame]; NSLog(@"rect.origin.x = %f",rect.origin.x); NSLog(@"rect.origin.y = %f",rect.origin.y); NSLog(@"rect.size.width = %f",rect.size.width); NSLog(@"rect.size.height = %f",rect.size.height); [panel setFrame:NSMakeRect(rect.origin.x, rect.origin.y-100, 200, 100) display:YES]; [NSApp activateIgnoringOtherApps:NO]; [panel makeKeyAndOrderFront:nil]; isPanelVisible = YES; } 
+4
source share
1 answer

NSPanels are typically translucent. See here for more details. If you do not need translucency, you can change the NSPanel in IB to a custom class from NSPanel to NSWindow.

+1
source

All Articles