How to get monospaced numbers in UILabel on iOS 9

前端 未结 8 1191
囚心锁ツ
囚心锁ツ 2020-12-13 06:52

At WWDC 2015, there was a session about the new “San Francisco” system font in iOS 9. It uses proportional number rendering instead of monospaced numbers by default when lin

8条回答
  •  悲哀的现实
    2020-12-13 07:14

    There has been quite some renaming in Swift 4, so the attributes now looks like this:

        let fontDescriptorAttributes = [
            UIFontDescriptor.AttributeName.featureSettings: [
                [
                    UIFontDescriptor.FeatureKey.featureIdentifier: kNumberSpacingType,
                    UIFontDescriptor.FeatureKey.typeIdentifier: kMonospacedNumbersSelector
                ]
            ]
        ]
    

提交回复
热议问题