SafeSFSymbols
安全访问SFSymbols。如果符号不可用,将显示警告。
// Replace this
UIImage(systemName: "star.fill")
// to this
UIImage(.star.fill)
社区
导航
安装
已在iOS 13+、tvOS 13+和watchOS 6+上准备好使用。
Swift包管理器
在Xcode中,转到项目 -> 您的项目名称 -> 包依赖项
-> 点击加号。插入url
https://github.com/sparrowcode/SafeSFSymbols
或将其添加到您的Package.swift
的dependencies
dependencies: [
.package(url: "https://github.com/sparrowcode/SafeSFSymbols", .upToNextMajor(from: "2.0.0"))
]
CocoaPods
这是一个过时的方法。我建议您使用SPM。然而,我将在一段时间内继续支持CocoaPods。
CocoaPods安装
CocoaPods是一个依赖项管理器。有关使用和安装说明,请访问他们的网站。要使用CocoaPods进行集成,请在您的Podfile
中指定它
pod 'SafeSFSymbols'
手动
如果您不希望使用任何依赖项管理器,您可以手动集成。将Sources/SafeSFSymbols
文件夹放入您的Xcode项目中。请确保启用需要时复制项目
和创建分组
。
使用方法
UIKit
let image = UIImage(.trash.circle)
SwiftUI
Image(.trash.circle)
AppKit
let image = NSImage(.trash.circle)
使用中的应用
如果您使用了SafeSFSymbols
,请通过Pull Request添加您的应用程序。