Question

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

Was it helpful?

Solution

You set the AppleAquaColorVariant preference:

[[NSUserDefaults standardUserDefaults] setInteger:NSGraphiteControlTint forKey:@"AppleAquaColorVariant"];

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 calling NSApplicationMain, or you can use a custom subclass of NSApplication, and call it in its -init method before [super init]

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top