1

I have created a UIlabel and UItextfield that correspond with each other. My new challenge is to have my font self-adjust its size to fill the UIlabel depending on how much text is entered. Solutions?

Hailei
  • 42,163
  • 6
  • 44
  • 69
Liam Dunker
  • 11
  • 1
  • 3

1 Answers1

3

UILabel has a property adjustsFontSizeToFitWidth. Please refer to UILabel Class Reference.

UITextField has a same one, see UITextField Class Reference.

You can set a big enough default font size and let the control reduce the text to fit the width. The actual font size will be between minimumFontSize and the size setting of font.

Hailei
  • 42,163
  • 6
  • 44
  • 69