Created
July 8, 2021 17:34
-
-
Save revblaze/b999020df1452f654c5b4af45a00ab3d to your computer and use it in GitHub Desktop.
Quick, typesafe SF Symbols extension for Swift(UI)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Symbol: String { | |
case add = "plus" | |
case trash = "trash" | |
case todo = "square" | |
case done = "checkmark.square" | |
} | |
/// Returns an image from the SF Symbols library | |
/// # Usage: Image(.trash) for Image(systemName: "trash") | |
extension Image { | |
init?(_ name: Symbol) { | |
self.init(systemName: name.rawValue) | |
} | |
} | |
// Check SFSymbols.swift for pre-symbol compatibility: | |
// https://gist.github.com/paulofierro/c035b67e5257444306eabc06054086e1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment