views:

21

answers:

1

I have a tableview and a normal view (let's say view 2) inside a normal view. All made in Interface builder. View 2 is above the tableview and needs to appear animated from above at the loading of the view. When pressing a button, the view disappears again. How can i do this?

thanks

+1  A: 

You will have to animate this in a custom animation block. It should be fairly simple.. Set your view's frame so that it is above the screen and not visible:

[yourView setFrame:CGRectMake(0, -480, 320, 480)];

In the animation block just change your view's frame in the animation block:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:GROW_AND_MOVE_ANIMATION_DURATION_SECONDS];
[yourView setFrame:CGRectMake(0, 0, 320, 480)];
[UIView commitAnimations];

To dismiss it/ make it disappear use same animation with the previous frame:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:GROW_AND_MOVE_ANIMATION_DURATION_SECONDS];
[yourView setFrame:CGRectMake(0, -480, 320, 480)];
[UIView commitAnimations];

But before that consider whether you must bring it in from top, cause if bringing it in from bottom as a modal view meets your requirements, you can very easily use UIViewController's method:

- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated

Good Luck.

lukya
But the presentModalViewController method won't work, because I think that is a UIView, not a UIViewController (Although I'm not sure)
Tom H
thank you for your answer.I actually did this and it worked:[UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:1]; [UIView setAnimationDelegate:self]; CGAffineTransform transformView = myView.transform; transformView = CGAffineTransformTranslate(transformView, 0, +210); myView.transform = transformView;I changed the beginnging coordinates in the interface builder.
DanielaM