UITextView * text =[[UITextView alloc]initWithFrame:CGRectMake(0, 100, 200, 20)];
[self.view addSubview:text];
text.backgroundColor =[UIColor lightGrayColor];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ValueChange:) name:UITextViewTextDidChangeNotification object:nil];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)ValueChange:(NSNotification *)obj
{
UITextView * textView = obj.object;
CGRect rect = textView.frame;
rect.size.height =textView.contentSize.height ;
textView.frame = rect ;
}
动态输入文字 uitextView的frame动态改变
最新推荐文章于 2019-08-22 14:51:32 发布