How to calculate TextView height base on text

前端 未结 6 2059
無奈伤痛
無奈伤痛 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 03:07

    self.textView.textContainerInset = UIEdgeInsets.zero self.textView.textContainer.lineFragmentPadding = 0

    In storyboard or xib mark textview height >=0.

    If you are using text view with table view. Calculate cell height according to content, textview will adjust it's space.

提交回复
热议问题