有没有一种方法可以在macOS SwiftUI开发中使用SF符号? [英] Is there a way to use SF Symbols in macOS SwiftUI development?

查看:137
本文介绍了有没有一种方法可以在macOS SwiftUI开发中使用SF符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SF Symbols提供了超过2400个一致的,高度可配置的符号集,您可以在应用程序中使用它们.苹果设计了SF Symbols来与San Francisco系统字体无缝集成,因此这些符号会自动确保与所有重量和大小的文本保持光学垂直对齐.

SF Symbols provides a set of over 2,400 consistent, highly configurable symbols you can use in your app. Apple designed SF Symbols to integrate seamlessly with the San Francisco system font, so the symbols automatically ensure optical vertical alignment with text in all weights and sizes.

https://developer.apple.com/设计/人机界面指南/sf-符号/概述/

据我所知,当尝试在macOS项目中使用SF Symbols时,macOS不支持 NSImage(systemName:String)语法.

As far as I can see, macOS does not support NSImage(systemName: String) syntax when trying to use SF Symbols in a macOS project.

具体地说,我试图在工具栏项上使用SF符号标志符号.

To be specific, I was trying to use an SF Symbol glyph on a toolbar item.

推荐答案

SF Symbol现在可用于 macOS 11 .

SF Symbol are now available with macOS 11.

SF Symbols在iOS 13和更高版本,macOS 11和更高版本,watchOS 6和更高版本以及tvOS 13和更高版本中可用.

SF Symbols are available in iOS 13 and later, macOS 11 and later, watchOS 6 and later, and tvOS 13 and later.

这是您的使用方式:

NSImage(systemSymbolName: "hammer", accessibilityDescription: nil)

如果要支持macOS 10.15及更低版本,则必须使用SF Symbols Mac应用程序并将该符号导出为SVG,然后将其导入回到Xcode项目中的资产文件中.您可以从此处获取该应用.

If you want to support macOS 10.15 and below you have to use the SF Symbols Mac app and export the symbol as SVG and import it back to an asset file in your Xcode project. You can get the app from here.

这篇关于有没有一种方法可以在macOS SwiftUI开发中使用SF符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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