This is USER-FRIENDLY SF Symbols.
You can use SF Symbols image without coding system names and if you select unavailable system image, you know it with the alert from Xcode.
Swift Package Manager(Recommended)
on Xcode, choose
Add Packages... → type url: https://github.com/littleossa/SFUserFriendlySymbols.git in the searchbox.
Add Package if
SFUserFriendlySymbols package appears.
You can also add this package to
Package.swift, include it in your target dependencies.
let package = Package( dependencies: [ .package(url: "https://github.com/littleossa/SFUserFriendlySymbols", .upToNextMajor(from: "0.1.0")), ], targets: [ .target( name: "<your-target-name>", dependencies: ["SFUserFriendlySymbols"]), ] )
📖 How to use
At first, import
for example, if you want use this system symbol named
symbol names changed into lower camel cases in SFUserFriendlySymbols.
face.smiling -> faceSmiling
select lower camel cased symbols as the parameter in the initializer.
let image = UIImage(symbol: .faceSmiling)
unfortunately,there are some symbol names which start with numbers.
the example is
1.circle.in this case,the enum case start with
let image = UIImage(symbol: ._1Circle)
❓ Why UserFriendly?
Why this name of SF Symbols library includes UserFriendly?
The symbol can’t use and you can know with the alert on Xcode when your lower OS target version doesn’t reach available version of the given symbol.
And also, you don’t need to type system name when you intialize images with any symbols.
There is just one word. “Happy”
🆕 Features from iOS 15
You can set image palette-colored or hiralical-colored, muluticolored.
use this symbol “pc” as a sample this time.
let image = UIImage(symbol: .pc, paletteColors: [.systemPink, .yellow])
let image = UIImage(symbol: .pc, hierarchicalColor: .systemPink)
if symbols have multicolor variant, the symbol’s color prefers the multicolor when they initialize with
let image = UIImage(multiColoredSymbol: .pc)
Feel free to contribute from SF Symbols lovers.
This library is released under the MIT License.