views:

96

answers:

1

Hi all,

Is it possible to make textfield come from above to down in an animated way when a button is pressed?

Thanx in advance.

A: 

Yes. You must chnage the frame of the UITextField inside an animation block. Something like this. Assuming, for example, that the Y origin of the text field before pressing the button is 0.0f (top of its container).

- (void) buttonPressed {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration: <desired_animation_duration_in_seconds> ];

    CGRect aFrame = _myTextField.frame;
    aFrame.origin.y = <desired_y_coord>;
    _myTextField.frame = aFrame;

    [UIView commitAnimations];
}
Espuz