问题
Is there a way to tell OS X to automatically style/tint a NSToolbarItem
?
I've added an "Image Toolbar Item" via IB/Xcode and set the icon to a black PDF as described in the documentation.
However, my result does not resemble that of, for instance, the App Store:
I'm looking for something akin to what the TabBar in iOS does by default.
I'm new to OS X development... So any guidance would be appriciated!
回答1:
Images need to be made template'd in order to get the correct styling (such as the engraved & blue styling).
This can be done in code with -[NSImage setTemplate:]
or by having your image names end with "Template" (requiring no code changes).
To get the blue styling specifically, you have to set a borderless NSButton as the custom view of the toolbar item (rather than it being a standard item). That button has to have a type that results in it showing its state (e.g. a Round-Textured Toggle button), and when it has an On state, it will get then blue styling.
来源:https://stackoverflow.com/questions/24599559/automatic-styling-tinting-of-nstoolbaritem