I have a UILabel square (yellow) that contains one letter.

I used the following code from this SO answer to adjust the font size so that it fits in UILabel :
letterLabel.font = UIFont(name: letterLabel.font.fontName, size: 100) letterLabel.adjustsFontSizeToFitWidth = true letterLabel.textAlignment = NSTextAlignment.Center
As you can see in the screenshot, the font size corresponds to the width. But since the text is only one letter, therefore, we must also look at the height. How can we adjust the font size so that the height is also within UILabel ?
source share