iOS How to get a monospace font for digits in UIFont.
Intoduction
This article shows how to set a monospace font for digits.
A monospace font has same width in each character.
Sometimes, a font which isn't monospace make the design baddly.
Solution
To get the monospace font for digits, Apple already prepare such a method for our developer in UIFont.
class func monospacedDigitSystemFont(ofSize fontSize: CGFloat, weight: UIFont.Weight) -> UIFont
So, we just need to call it.
myLabel.font = UIFont.monospacedDigitSystemFont(ofSize: 17 weight: UIFont.Weight.regular)