简体   繁体   English

我可以在我的应用程序中使用系统的触摸栏图标吗?

[英]Can I use the system Touch Bar icons in my app?

I am trying to add a "New" button and a "Search" button for my app onto the Touch Bar. 我试图将我的应用程序的“新建”按钮和“搜索”按钮添加到触摸栏中。 In system apps, these are a plus sign and a magnifying glass, respectively. 在系统应用程序中,它们分别是加号和放大镜。 Is there a way to use these system icons on my touch bar buttons, such as in UIBarButtonItems? 有没有办法在我的触摸栏按钮上使用这些系统图标,例如UIBarButtonItems? If not, how can I set a touch bar button's content to be a magnifying glass or plus sign? 如果没有,如何将触摸栏按钮的内容设置为放大镜或加号? I am using Swift. 我正在使用Swift。 Thanks. 谢谢。

Maybe you could find those icons in the system files, copy them and use them in your application, but I would not recommend it. 也许您可以在系统文件中找到这些图标,然后将其复制并在您的应用程序中使用它们,但我不建议这样做。 They are Apple's intellectual property and you are not allowed to use them for public projects. 它们是Apple的知识产权,您不得将它们用于公共项目。

You should search on sites like flaticon.com for similar artworks or create them yourself. 您应该在flaticon.com之类的网站上搜索类似的艺术品或自己创建。

Apple provides many system icons that you can use in your app. Apple提供了许多可以在应用程序中使用的系统图标。 The Human Interface Guidelines has a nice visual reference of all of the icons available here . 人机界面指南对此处提供的所有图标都有很好的视觉参考。 These can be referenced in your app by using the associated NSImage.Name constant (also described in the HIG). 可以通过使用关联的NSImage.Name常量(也在HIG中进行描述)在您的应用程序中引用它们。

As an example, the new and search images can be gotten using: 例如,可以使用以下命令获取新图像和搜索图像:

let addImage = NSImage(named: .touchBarAddTemplate)
let searchImage = NSImage(named: .touchBarSearchTemplate)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM