UITextView高度自适应

UITextView高度自适应

2023年7月14日发(作者:)

UITextView⾼度⾃适应- (void)awakeFromNib { [super awakeFromNib]; // Initialization code ionStyle=UITableViewCellSelectionStyleNone; oundColor=LineColor; te=self; Width=2*PIX; Color=[UIColor lightGrayColor].CGColor; oBounds=YES; Radius=5; =[UIFont systemFontOfSize:14]; //加下⾯⼀句话的⽬的是,是为了调整光标的位置,让光标出现在UITextView的正中间 ntainerInset = UIEdgeInsetsMake(10, 5, 10, 5); DLog(@"1---->%f",);}//实现textViewDidChange⽅法:-(void)textViewDidChange:(UITextView *)textView{ if (>0) { =YES; }else{ =NO; } static CGFloat maxHeight =100.0f; static CGFloat minHeight =38.0f; CGRect frame = ; CGSize constraintSize = CGSizeMake(, MAXFLOAT); CGSize size = [textView sizeThatFits:constraintSize]; // if (<=) { if (= maxHeight){ = maxHeight; Enabled = YES; // 允许滚动 }else{ Enabled = NO; // 不允许滚动 } } nt = ; [iew beginUpdates]; [iew endUpdates]; k(textView);

}

发布者:admin,转转请注明出处:http://www.yc00.com/web/1689265724a226479.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信