【问题标题】:Why my NSPanel doesn't have background of gray color as normal?为什么我的 NSPanel 没有正常的灰色背景?
【发布时间】:2012-12-02 13:28:29
【问题描述】:

我的应用在菜单栏中有一个图标。当我单击图标时,会出现NSPanel。但是为什么NSPanel 没有像其他具有灰色背景NSWindow 的背景颜色?我的NSPanel 的背景看起来像透明的。我的NSPanel 来自.xib 文件。我的代码如下:

(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;
}

【问题讨论】:

    标签: objective-c macos cocoa nspanel


    【解决方案1】:

    NSPanel 通常是半透明的。请参阅here 了解更多信息。如果您不想要半透明,您可以将自定义类下的 IB 中的 NSPanel 从 NSPanel 更改为 NSWindow。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-04
      • 1970-01-01
      • 2011-08-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-28
      相关资源
      最近更新 更多