Autoshrink on a UILabel with multiple lines

前端 未结 17 2059
醉梦人生
醉梦人生 2020-11-28 21:31

Is it possible to use the autoshrink property in conjunction on multiple lines on a UILabel? for example, the large text size possible on 2 available lines.

17条回答
  •  没有蜡笔的小新
    2020-11-28 22:10

    I cannot comment the post of MontiRabbit due to reputation lacking, so i'll make a new answer. The solution he (and her referrer) proposed do not work on Xcode 7.3 or better, it's imprecise. To make it work, in storyboard, I had to:

    1. Set a width constraint (pure width or tail&lead)
    2. SET an HEIGHT CONSTRAINT (this is very important, normally with autoresize one does not set the label height)
    3. Set "Autoshrink" property to "Minimum font scale" or "Minimum font size" (works in both cases)
    4. Set "Line Breaks" property to "Truncate Tail"
    5. Set "Lines" property to a non-zero value

    Hope it helps! ;)

提交回复
热议问题