- (void) animateTextField: (UITextView*)textField up:(BOOL) up
{
const int movementDistance = 300;
const float movementDuration = 0.4f;
int movement = (up ? -movementDistance : movementDistance);
[UIView beginAnimations: @"anim" context: nil];
[UIView setAnimationBeginsFromCurrentState: YES];
[UIView setAnimationDuration: movementDuration];
self.view.frame = CGRectOffset(self.view.frame, 0, movement);
[UIView commitAnimations];
}
//in text field didbegin editing method call above one
- (void)textViewDidBeginEditing:(UITextView *)textField
{
if (txtField.frame.origin.y > 150)
[self animateTextField:textField up: YES];
}
//and when ever user pressed done button on keyboard for view to come down write below method
- (void)textViewDidEndEditing:(UITextView *)textField
{
if (txtField.frame.origin.y > 150)
[self animateTextField:textField up: NO];
}
No comments:
Post a Comment