Multiline UILabel with adjustsFontSizeToFitWidth

前端 未结 8 1498
北海茫月
北海茫月 2020-12-04 12:16

I have a multiline UILabel whose font size I\'d like to adjust depending on the text length. The whole text should fit into the label\'s frame without truncating it.

8条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 12:40

    It seems to me that there is now a better answer to this question

    I have discovered that the font size adjusts automatically on a multiline label when you set adjustsFontSizeToFitWidth true, numberOfLines 0, a minimumScaleFactor little enough to let the font shrink as needed, and the default lineBreakMode (byTruncatingTail)

    PS: I cannot find anything about this change on the official documentation. I created a question to find out more informations on this topic here

提交回复
热议问题