美文网首页
UITextView自适应文字高度

UITextView自适应文字高度

作者: 豆汁儿还是豆花儿 | 来源:发表于2020-05-25 15:14 被阅读0次

  textView.textContainerInset = UIEdgeInsetsZero;

  textView.textContainer.lineFragmentPadding = 0;

只需要以上两行代码即可。这样我们在UITextView中设置的文字就可以左右两边对齐显示,且自适应高度,可自由滑动。

[textView scrollRangeToVisible:NSMakeRange(0, 0)];//解决UITextContainer布局被遮挡问题

相关文章

网友评论

      本文标题:UITextView自适应文字高度

      本文链接:https://www.haomeiwen.com/subject/pnuyahtx.html