苹果专用图标资源库 SF Symbols 简单使用

SF Symbols 是苹果公司提供的一套系统图标资源库,专门用于开发 iOS、iPadOS 和 macOS 应用程序,目前拥有超过 4400 个图标符号,涵盖各种常见的应用程序界面元素和符号,如按钮、导航栏、工具栏、标签、图标等等。

SF Symbols 的设计风格符合苹果的界面规范和视觉风格,开发者可以在 Xcode 中直接访问 SF Symbols 图标库,并用于按钮、标签、导航栏等界面元素的设计。SF Symbols 还能灵活的调整大小、颜色和渲染效果,使图标可以根据需求进行动态调整。

SF Symbols 不仅仅是一个图标。它可以完美的和文本一起展示。因为它的每一个图表都有九种大小粗细属性可以刚好对应 San Francisco 系统字体的大小粗细。


苹果专用图标资源库 SF Symbols 简单使用
SF Symbols 不同的Size、Width

系统要求

 SF Symbols 要求在 iOS 13 及更高版本、watchOS 6 及更高版本以及 tvOS 13 及更高版本中使用 。

使用限制

只能在 UI 图标使用 SF Symbols,同时需要同意 Apple 的许可协议,如:

All SF Symbols shall be considered to be system-provided images as defined in the Xcode and Apple SDKs license agreements and are subject to the terms and conditions set forth therein. You may not use SF Symbols — or glyphs that are substantially or confusingly similar — in your app icons, logos, or any other trademark-related use. Apple reserves the right to review and, in its sole discretion, require modification or discontinuance of use of any Symbol used in violation of the foregoing restrictions, and you agree to promptly comply with any such request.

另一个限制

一些代表 Apple 技术的图标不能用于其他用途,只能展示它原本所代表的的功能。例如,iCloudAirPlayFacetime 等符号。请务必访问Apple 人机界面指南中的按原样使用符号,通常这些图标有 标记,请注意使用。


如何使用 SF Symbols

Apple 中把 SF Symbols 视为图像。所以需要使用 Image 图像容器来包装初始化它

Swift 使用

UIImage(systemName: "house.fill")

SwiftUI 使用

Image(systemName: "house.fill")

设置 scale

可以使用 SymbolConfiguration 设置图标比例

Swift 使用

let smallConfiguration = UIImage.SymbolConfiguration(scale: .small)
let image = UIImage(systemName: "house.fill", withConfiguration: configuration)

SwiftUI 使用

Image(systemName: "house.fill").imageScale(.small)

下载使用

官网地址: https://developer.apple.com/sf-symbols/

  本文自 https://www.codeun.com 发布,相应代码均自主编写并严格审阅和测试,完整代码中包含丰富的学习笔记和使用方式、实用技巧。
  · 如若转载,请注明出处:https://www.codeun.com/archives/1106.html ·

(0)
上一篇 2023-05-25
下一篇 2023-06-04

相关推荐

发表回复

登录后才能评论