Guest User

Untitled

a guest
Feb 23rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import UIKit
  2.  
  3. extension UIFont {
  4.  
  5. var monospacedDigitFont: UIFont {
  6. let oldFontDescriptor = fontDescriptor
  7. let newFontDescriptor = oldFontDescriptor.monospacedDigitFontDescriptor
  8. return UIFont(descriptor: newFontDescriptor, size: 0)
  9. }
  10.  
  11. }
  12.  
  13. private extension UIFontDescriptor {
  14.  
  15. var monospacedDigitFontDescriptor: UIFontDescriptor {
  16. let fontDescriptorFeatureSettings = [[UIFontDescriptor.FeatureKey.featureIdentifier: kNumberSpacingType, UIFontDescriptor.FeatureKey.typeIdentifier: kMonospacedNumbersSelector]]
  17. let fontDescriptorAttributes = [UIFontDescriptor.AttributeName.featureSettings: fontDescriptorFeatureSettings]
  18. let fontDescriptor = self.addingAttributes(fontDescriptorAttributes)
  19. return fontDescriptor
  20. }
  21. }
Add Comment
Please, Sign In to add comment