Cocoa HUD 窗口:删除透明度?
我有一个标准 NSPanel 设置为 HUD 样式。我想更改背景颜色,主要是因为我想要一个工具栏,但没有看到任何使标准 nstoolbar 在 HUD 上看起来不错的方法,也没有看到直接自定义工具栏背景的方法。
我知道创建完全自定义窗口的方法有多种,并在其他情况下使用这些方法。在这种情况下,我想要窗口提供的所有好处,但我只是不想要透明度。有趣的是,我可以更改背景颜色,但不能更改 Alpha。设置 alpha 值对窗口没有影响。
以前有人解决过这个问题吗?
I have a standard NSPanel set to HUD style. I want to change the background color, primarily because I want to have a toolbar and don't see any way of making either a standard nstoolbar look good on a HUD nor a way of customizing the background of a toolbar directly.
I am aware of the multitude of ways for creating a completely custom window, and use those in other circumstances. In this case, I want all of the good things that a window provides, but I just don't want transparency. Interestingly, I can change the background color, but not the alpha. Setting alpha values has no effect on the window.
Anyone solved this problem before?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将面板的内容视图(只需在面板内单击即可选择它,而不是标题栏)子类设置为
SGPanelView
,并使用您的 drawRect 方法的实现来创建SGPanelView
类:SGPanelView,NSView 的子类:应该可以工作。如果不起作用,请尝试将
bounds
更改为frame
。请参阅 http://developer .apple.com/library/mac/#documentation/cocoa/reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html 了解更多信息。
Set the panel's content-view's (just click inside the panel to select it, not the titlebar) subclass to
SGPanelView
and make thatSGPanelView
with this implementation of a drawRect method of your class: SGPanelView, a subclass of NSView:Should work. If not working, try changing
bounds
toframe
.See http://developer.apple.com/library/mac/#documentation/cocoa/reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html for more information.