NSToolbarItem的自动样式/着色 [英] Automatic Styling/Tinting of NSToolbarItem

查看:191
本文介绍了NSToolbarItem的自动样式/着色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以告诉OS X自动设置NSToolbarItem的样式/色调?

Is there a way to tell OS X to automatically style/tint a NSToolbarItem?

我通过IB/Xcode添加了图像工具栏项",并将图标设置为黑色PDF

I've added an "Image Toolbar Item" via IB/Xcode and set the icon to a black PDF as described in the documentation.

但是,我的结果与App Store的结果不同:

However, my result does not resemble that of, for instance, the App Store:

我正在寻找类似于默认情况下iOS中的TabBar的功能.

I'm looking for something akin to what the TabBar in iOS does by default.

我是OS X开发的新手,所以任何指导都适用!

I'm new to OS X development... So any guidance would be appriciated!

推荐答案

需要对图像进行模板处理才能获得正确的样式(例如雕刻的&蓝色样式).

Images need to be made template'd in order to get the correct styling (such as the engraved & blue styling).

这可以通过使用-[NSImage setTemplate:] 的代码来完成,方法是将图像名称以"Template"结尾(无需更改代码).

This can be done in code with -[NSImage setTemplate:] or by having your image names end with "Template" (requiring no code changes).

要特别获得蓝色样式,必须将无边界NSButton设置为工具栏项的自定义视图(而不是标准项).该按钮必须具有导致其显示其状态的类型(例如,圆形纹理的切换"按钮),并且当其处于打开"状态时,它将具有蓝色样式.

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.

这篇关于NSToolbarItem的自动样式/着色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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