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?

2
  • coded programmically Aug 26, 2017 at 6:46
  • try this label.adjustsFontSizeToFitWidth = true Aug 26, 2017 at 7:00

1 Answer 1

6

Swift 3...

label.minimumScaleFactor = 0.1    //you need
label.adjustsFontSizeToFitWidth = true    
label.lineBreakMode = .byClipping
label.numberOfLines = 0
1
  • 2
    Wow. Thank you so much. The error for mine was numerOfLines = 1 Aug 26, 2017 at 7:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.