Skip to content

littleossa/SFUserFriendlySymbols

Repository files navigation

SFUserFriendlySymbols

SFUserFriendlySymbols

CI

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.

♥️ Support SF Symbols version

Supported SF Symbols 3.3 now.

⬇️ Installation

Swift Package Manager(Recommended)

on Xcode, choose FileAdd Packages... → type url: https://github.com/littleossa/SFUserFriendlySymbols.git in the searchbox. searchbox

tap 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.2.2")),
    ],
    targets: [
        .target(
            name: "<your-target-name>",
            dependencies: ["SFUserFriendlySymbols"]),
    ]
)

📖 How to use

At first, import SFUserFriendlySymbols.

◆ UIKit

for example, if you want use this system symbol named face.smiling

face-smiling

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.

1Circle

the example is 1.circle.in this case,the enum case start with _.

let image = UIImage(symbol: ._1Circle)

◆ SwiftUI

Image(symbol: .faceSmiling)

◆ Categorized Symbols

There are 23 categories as with that you can see on SF Symbols App. they return symbols which can use on your target os version.

All Symbols

SFSymbols.allCases

or

SFSymbols.Category.all.symbols

Other categories

For example, when you use symbols categorized as Weather

let weatherSymbols = SFSymbols.Category.weather

or

let weatherSymbols = SFSymbols.weatherSymbols

❓ 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.

sfsymbols-alert

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.

pc

palette-colored

let image = UIImage(symbol: .pc, paletteColors: [.systemPink, .yellow])

palette-color

hierarchical-colored

let image = UIImage(symbol: .pc, hierarchicalColor: .systemPink)

hierirchcal-color

multicolored

if symbols have multicolor variant, the symbol's color prefers the multicolor when they initialize with UIImage(multiColoredSymbol:)

let image = UIImage(multiColoredSymbol: .pc)

multicolor

💡 Contribution

Feel free to contribute from SF Symbols lovers.

License

This library is released under the MIT License.

Reference

I blogged about SFUserFriendlySymbols in Japanse.the link is below.