我想将我的应用程序的默认系统控制色调覆盖为 always NSGraphiteControlTint
。以下代码似乎不起作用。有什么建议么?
NSButton *button = [window standardWindowButton:NSWindowCloseButton];
[[button cell] setControlTint:NSGraphiteControlTint];
问候, 埃里克
我想将我的应用程序的默认系统控制色调覆盖为 always NSGraphiteControlTint
。以下代码似乎不起作用。有什么建议么?
NSButton *button = [window standardWindowButton:NSWindowCloseButton];
[[button cell] setControlTint:NSGraphiteControlTint];
问候, 埃里克
您设置 AppleAquaColorVariant 首选项:
[[NSUserDefaults standardUserDefaults] setInteger:NSGraphiteControlTint forKey:@"AppleAquaColorVariant"];
但是,如果您希望它在应用程序第一次启动时工作,您必须在绘制任何 UI 之前,在main
调用之前执行它NSApplicationMain
,或者您可以使用自定义子类NSApplication
,并在其-init
方法之前调用它[super init]
并非所有控件都会尊重控件色调。对于窗口按钮等应用程序很少使用的控件,这种情况更有可能发生。
该代码看起来正确。要验证它,请在单选按钮或按钮之类的东西上试一试。
要获得一个看起来像关闭按钮的灰色版本的小按钮,我认为您将不得不使用带有自定义图形的按钮或您自己的带有自定义绘图的子类。