whyceewhite / CarLess

Logging commuting trips completed using transit or pedestrian modes of transportation.
0 stars 0 forks source link

Distance number on log tracked entry progress screen should be monospace #68

Closed whyceewhite closed 9 years ago

whyceewhite commented 9 years ago

On the log tracked entry progress scene, the distance value lable is centered. When the distance number is changing, the text appears to jump because the numbers are not monospaced. Figure out a way to make the preferred font monospace so that it appears still.

whyceewhite commented 9 years ago

This Using fonts with Text Kit reference provided information on monospacing the font for a numerical element.

Here's an example of how I did it:

        let font = UIFont.preferredFontForTextStyle(UIFontTextStyleTitle1)
        let fontDescriptor = font.fontDescriptor()
        var fontAttributes = [String : AnyObject]()
        fontAttributes[UIFontDescriptorFeatureSettingsAttribute] = [
            [
                UIFontFeatureTypeIdentifierKey : kNumberSpacingType,
                UIFontFeatureSelectorIdentifierKey : kMonospacedNumbersSelector
            ]
        ]
        let propDescriptor = fontDescriptor.fontDescriptorByAddingAttributes(fontAttributes)
        return UIFont(descriptor: propDescriptor, size: 0)