#import "ViewController.h"
@interface ViewController ()<UITextViewDelegate>
@property (strong, nonatomic) UITextView *textView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self.view addSubview:self.textView];//加载textView
}
-(UITextView *)textView{
if (!_textView) {
_textView=[[UITextView alloc]initWithFrame:CGRectMake(30, 200, CGRectGetWidth([[UIScreen mainScreen] bounds])-60, 30)];
[_textView setTextColor:[UIColor redColor]];
[_textView.layer setBorderColor:[[UIColor blackColor] CGColor]];
[_textView setFont:[UIFont systemFontOfSize:15]];
[_textView.layer setBorderWidth:1.0f];
[_textView setDelegate:self];
}
return _textView;
}
-(void)textViewDidChange:(UITextView *)textView{
static CGFloat maxHeight =60.0f;
CGRect frame = textView.frame;
CGSize constraintSize = CGSizeMake(frame.size.w
iOS——自适应textView
最新推荐文章于 2021-11-27 11:03:07 发布
本文探讨了在iOS开发中如何实现textView的高度自适应,基于实际项目经验分享了相关源码,供开发者参考和下载。
摘要由CSDN通过智能技术生成