Created
March 8, 2017 16:17
-
-
Save Marcocanc/9ffc1894743367173012b9d66e8b3ad8 to your computer and use it in GitHub Desktop.
really hoping this will work out of the box in future versions
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
public extension UIFont { | |
public class func systemFont(ofSize fontSize: CGFloat, weight: UIFontWeight) -> UIFont { | |
return .systemFont(ofSize: fontSize, weight: weight.floatValue) | |
} | |
public class func monospacedDigitSystemFont(ofSize fontSize: CGFloat, weight: UIFontWeight) -> UIFont { | |
return .monospacedDigitSystemFont(ofSize: fontSize, weight: weight.floatValue) | |
} | |
} | |
public enum UIFontWeight { | |
case ultralight | |
case thin | |
case light | |
case regular | |
case medium | |
case semibold | |
case bold | |
case black | |
case heavy | |
public var floatValue: CGFloat { | |
switch self { | |
case .ultralight: | |
return UIFontWeightUltraLight | |
case .thin: | |
return UIFontWeightThin | |
case .light: | |
return UIFontWeightLight | |
case .regular: | |
return UIFontWeightRegular | |
case .medium: | |
return UIFontWeightMedium | |
case .semibold: | |
return UIFontWeightSemibold | |
case .bold: | |
return UIFontWeightBold | |
case .black: | |
return UIFontWeightBlack | |
case .heavy: | |
return UIFontWeightHeavy | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment