Created
June 26, 2015 15:09
-
-
Save samuel-mellert/a0419641895ff4c2ba82 to your computer and use it in GitHub Desktop.
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
extension UIFont { | |
static func monospacedDigitsSystemFontOfSize(fontSize: CGFloat, weight: CGFloat) -> UIFont { | |
let originalFontDescriptor = UIFont.systemFontOfSize(fontSize, weight: weight).fontDescriptor() | |
let fontDescriptorFeatureSettings = [ | |
[ | |
UIFontFeatureTypeIdentifierKey: kNumberSpacingType, | |
UIFontFeatureSelectorIdentifierKey: kMonospacedNumbersSelector | |
] | |
] | |
let fontDescriptorAttributes = [UIFontDescriptorFeatureSettingsAttribute: fontDescriptorFeatureSettings] | |
let fontDescriptor = originalFontDescriptor.fontDescriptorByAddingAttributes(fontDescriptorAttributes) | |
return UIFont(descriptor: fontDescriptor, size: 0) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah, you are right. They seem to have fixed this with beta 4! Great to know. 👍