UILabel is not auto-shrinking text to fit label size

后端 未结 17 613
感动是毒
感动是毒 2020-12-04 06:53

I have this strange issue, and im dealing with it for more than 8 hours now.. Depending on situation i have to calculate UILabels size dynamically,
e.g

17条回答
  •  一生所求
    2020-12-04 07:29

    Swift 4, Xcode 9.4.1

    The solution that worked for me: I had a label within a collection view cell, and the label text was getting trimmed. Set the attributes as below on Storyboard

    Lines = 0
    LineBreak = Word Wrap
    Set yourlabel's leading and trailing constraint = 0 (using Autolayout)
    

提交回复
热议问题