To change the size of a UITextView to its contents i.e as the content of the UITextView increases the size of the textview will also increase.
We can implement this by applying the following code :-
- (void)textViewDidChange:(UITextView *)textView
{
CGFloat fixedWidth = textView.frame.size.width;
CGSize newSize = [textView sizeThatFits:CGSizeMake(fixedWidth, MAXFLOAT)];
CGRect newFrame = textView.frame;
newFrame.size = CGSizeMake(fmaxf(newSize.width, fixedWidth), newSize.height);
textView.frame = newFrame;
}
Remember we have to set the delegate of UITextView also..
0 Comment(s)