How would I go about animating open a textviewto expand when开发者_Python百科 clicked? So if I have a UITextView that is of height 30 but when it gains focus have it expand to 100. Then on losing focus have it go back to 30 even if the text is of height 100.
TIA
Look into the UITextViewDelegate methods -textViewDidBeginEditing:
and -textViewDidEndEditing:
Interesting you ask this, because I literally just figured out how to do the same thing. Call this method whenever you want to resize your textview:
-(IBAction)resizeFrame {
textView.frame = CGRectMake(x, y, width, height);
[self.view bringSubviewToFront:questions];
}
Line 1 sets the frame of the textView as a rectangle starting at point x,y with whatever width and height you specify.
Line 2 brings this view to the front so that you can actually see it!
If you want to size it back down, call another method with a different name that sets the CGRect back to the textView's original size.
精彩评论