Swift - Adjusting fontSize to fit the width of the layout (programmatically)

后端 未结 1 993
南方客
南方客 2021-02-11 13:21

I\'ve been looking for something to dynamically adjust my fontSize to fit the width of my layout box. But all the answers I can find, is either to use this:

1条回答
  •  失恋的感觉
    2021-02-11 14:04

    Try the following commands for your label:

    label.adjustsFontSizeToFitWidth = true
    label.minimumScaleFactor = 0.2
    

    And try to change the lines of the label to 0 and 1 (check both cases):

    label.numberOfLines = 0 // or 1
    

    0 讨论(0)
提交回复
热议问题