Toggle NSToolbarItem between Black and Blue

半世苍凉 提交于 2019-12-21 09:27:08

问题


I'd like to make an NSToolbarItem with a custom image which toggles between Black and Blue, like the icons at the top right of Xcode 5's main window.

Peter Hosey suggested in this answer that it was as simple as setting the image to be a template, but I haven't found that to be the case. I set it to a template image, and that causes it properly render the dark gray gradient, but it doesn't render in blue when toggled.

I uploaded a very simple example of what I've done, here. If someone could tell me how to change it to light up the NSToolbarItem in blue, as Xcode does, then I'd very much appreciate it.


回答1:


You mostly have everything you need in place, with the exception of providing an NSButton object using the style NSTexturedRoundedBezelStyle, with which you’ve associated your image.

↳ modified example project here

⌘ OS X Human Interface Guidelines | Window-Frame Controls



来源:https://stackoverflow.com/questions/20852239/toggle-nstoolbaritem-between-black-and-blue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!