-
(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
CGRect frame = textView.frame;
float height;
if ([text isEqual:@""]) {if (![textView.text isEqualToString:@""]) { height = [ self heightForTextView:textView WithText:[textView.text substringToIndex:[textView.text length] - 1]]; }else{ height = [ self heightForTextView:textView WithText:textView.text]; }
}else{
height = [self heightForTextView:textView WithText:[NSString stringWithFormat:@"%@%@",textView.text,text]];
}
frame.size.height = height;
[UIView animateWithDuration:0.5 animations:^{textView.frame = frame; } completion:nil];
return YES;
}
网友评论