How to adjust a label size to fit the length of the text

前端 未结 8 729
无人及你
无人及你 2020-12-20 12:27

I have searched the solution to this in the past QAs, but could not find the right one.
Does anyone know how to adjust aUILabel size dynamically to fit the

8条回答
  •  失恋的感觉
    2020-12-20 12:37

    All you need to just put 2 lines code

    lbl1.numberOfLines = 0
        lbl1.sizeToFit()
    

    It will manage label width as per its content

    Hope it helps others :)

提交回复
热议问题