更改窗口按钮的控制色调
我想将我的应用程序的默认系统控制色调覆盖为始终 NSGraphiteControlTint
。但下面的代码似乎不起作用。有什么建议吗?
NSButton *button = [window standardWindowButton:NSWindowCloseButton];
[[button cell] setControlTint:NSGraphiteControlTint];
问候, 埃里克
I'd like to override the default system control tint for my app to be always NSGraphiteControlTint
. The following code doesn't seem to work though. Any suggestions?
NSButton *button = [window standardWindowButton:NSWindowCloseButton];
[[button cell] setControlTint:NSGraphiteControlTint];
Regards,
Erik
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您设置 AppleAquaColorVariant 首选项:
但是,如果您希望它在应用程序第一次启动时工作,则必须在绘制任何 UI 之前(在调用 NSApplicationMain 之前在
main
中执行此操作) ,或者您可以使用NSApplication
的自定义子类,并在[super init]
之前在其-init
方法中调用它You set the AppleAquaColorVariant preference:
However, if you want it to work the first time the app launches, you must do it before any UI is drawn, in
main
before callingNSApplicationMain
, or you can use a custom subclass ofNSApplication
, and call it in its-init
method before[super init]
并非所有控件都会遵循控件色调。对于窗口按钮等应用程序很少使用的控件来说,这种情况更可能发生。
该代码看起来是正确的。要验证它,请在单选按钮或按钮之类的东西上尝试一下。
要获得一个看起来像关闭按钮的灰色版本的小按钮,我认为您将必须使用带有自定义图形的按钮或带有自定义绘图的您自己的子类。
Not all controls are going to respect the control tint. This is even more likely for controls that are rarely used by apps like the window buttons.
That code looks correct. To verify it, try it on something like a radio button or a push button.
To get a small button that looks like a gray version of the close button I think you are going to have to use a button with custom graphics or your own subclass with custom drawing.