在黑色和蓝色之间切换NSToolbarItem [英] Toggle NSToolbarItem between Black and Blue

查看:94
本文介绍了在黑色和蓝色之间切换NSToolbarItem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个带有自定义图像的NSToolbarItem,该图像可以在黑色和蓝色之间切换,就像Xcode 5主窗口右上角的图标一样.

彼得·霍西(Peter Hosey)在此答案中建议,就像将图像设置为模板一样简单,但是我没有事实并非如此.我将其设置为模板图像,这会导致其正确呈现深灰色渐变,但切换后不会呈现蓝色.

我在这里上传了一个非常简单的示例.如果有人可以告诉我如何进行更改(如Xcode那样以蓝色点亮NSToolbarItem),那么我将不胜感激.

解决方案

除了使用样式 NSTexturedRoundedBezelStyle 提供的 NSButton 对象外,您几乎已拥有所需的一切. strong>,您已将其与图像相关联.

此处的示例项目已修改

OS X人机界面指南|窗口框架控件

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.

解决方案

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

这篇关于在黑色和蓝色之间切换NSToolbarItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆