Last active
October 18, 2018 04:29
-
-
Save joninsky/a32f6353b083a27f32e5394273e2d035 to your computer and use it in GitHub Desktop.
Struct that represents the necessary functions and properties to get started using the IcoMoon free pack.
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
import UIKit | |
/// Struct that lets you access the linear icons in code. | |
struct IconFont { | |
//MARK: Properties | |
/// The name of the IcoMoon-Free file used ot register the font. | |
let iconFontName = "IcoMoon-Free" | |
/// Upstanding up arrow | |
let arrow_up = "\u{ea3a}" | |
/// Righteous right arrow | |
let arrow_right = "\u{ea3c}" | |
/// Demeaning down arrow | |
let arrow_down = "\u{ea3e}" | |
/// Left over left arrow. | |
let arrow_left = "\u{ea40}" | |
init() { | |
} | |
/// Function that will serve up a `UIFont` object that represents the Linear Icon Font. Will dynamically register the font using the font extension if the font has not been registered. | |
/// | |
/// - Parameter size: The size of the font | |
/// - Returns: The font you always wanted. | |
func iconFont(_ size: CGFloat) -> UIFont { | |
guard let font = UIFont(name: self.iconFontName, size: size) else { | |
let _ = UIFont.registerFont(fontName: self.iconFontName, fontExtension: "ttf") | |
return self.iconFont(size) | |
} | |
return font | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment