objective-c – 为什么我的NSPanel没有正常的灰色背景?

objective-c – 为什么我的NSPanel没有正常的灰色背景?,第1张

概述我的应用程序在菜单栏中有一个图标.单击图标时会显示NSPanel.但是为什么NSPanel没有像其他具有灰色背景NSWindow的背景颜色?我的NSPanel的背景看起来很透明.我的NSPanel来自.xib文件.我的代码如下: (void)openPanel{NSLog(@"openPanel");NSWindow *panel = self.panelController.windo 我的应用程序在菜单栏中有一个图标.单击图标时会显示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;}
解决方法 通常NSPanel是半透明的.有关更多信息,请参见 here.如果您不想要半透明,则可以将自定义类中IB中的NSPanel从NSPanel更改为NSWindow. 总结

以上是内存溢出为你收集整理的objective-c – 为什么我的NSPanel没有正常的灰色背景?全部内容,希望文章能够帮你解决objective-c – 为什么我的NSPanel没有正常的灰色背景?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1072173.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存