-(void)textViewDidChange:(UITextView *)textView{
if (textView.frame.size.height>100) {//当textview的高度到100时,返回
return;
}
<p class="p1"><span class="s1"><span> </span>CGfloat height = [textView </span><span class="s2">sizeThatFits</span><span class="s1">:</span><span class="s2">CGSizeMake</span><span class="s1">(textView.</span><span class="s3">frame</span><span class="s1">.</span><span class="s3">size</span><span class="s1">.</span><span class="s3">width</span><span class="s1">, </span><span class="s4">FLT_MAX</span><span class="s1">)].</span><span class="s3">height</span><span class="s1">;</span></p> //设置高度
textView.frame = CGRectMake(20, 30, 100, height);
}
textview 自适应高度
最新推荐文章于 2023-12-26 09:09:34 发布