How to calculate TextView height base on text

前端 未结 6 2023
無奈伤痛
無奈伤痛 2021-01-05 02:43

I am using the code below for calculate the height of text, then set this height for UILabel and UITextView

CGSize targetSize = CGS         


        
6条回答
  •  孤城傲影
    2021-01-05 02:59

    You don't need to calculate Height of UITextview based on text.

    Just change frame and set height like this:

    textview.size.height = textview.contentSize.height;
    

    This is easy solution. I hope this helps you.

提交回复
热议问题