Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to adjust font size to fit height (not width) in swift 3

label.minimumScaleFactor works very well to fit the font to the width.

However the font size, for alphabet such as "I", is typically larger than other letters such as "H". This makes the design very weird.

I need help to fit the font to the label height. Any solutions/functions/class that I can adopt?

like image 496
Lew Gao Wei Avatar asked Oct 14 '25 15:10

Lew Gao Wei


1 Answers

Swift 3...

label.minimumScaleFactor = 0.1    //you need
label.adjustsFontSizeToFitWidth = true    
label.lineBreakMode = .byClipping
label.numberOfLines = 0
like image 139
Arjun Yadav Avatar answered Oct 17 '25 07:10

Arjun Yadav



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!