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

前端 未结 8 744
无人及你
无人及你 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:32

    Currently i m working on IOS-8 and there is small changes i made to @Suragch answer (Need to use auto layout to make this work)

    Below is the step and screenshot in result :

    1. Place the textview inside UIView and not directly inside content-view in storyboard
    2. Disable scroll of textview from storyboard
    3. Add Leading and top constraints as i have added to view in below screenshot(Trailing constraint is optional but i have added )

    There is no need to add code in swift this can be done in storyboard itself.

    Result :

提交回复
热议问题