Earl Grey
Earl Grey

Reputation: 7466

Hiding an animated modal UIView?

I need to present and then dismiss a UITableView modally. It should animate in from top to button. But it should not cover the whole screen, it will slide in from under navigation bar and stop before it reaches the tabbar.

So i can't use the presentViewController:animated:completion: for its view controller. I need to manipulate it as part of a view hierarchy. The question is, where should this table view be when it is not visible. Where will I animate it from?

Upvotes: 1

Views: 122

Answers (1)

boostedz06
boostedz06

Reputation: 319

You could put the UITableView inside a UIView and use animateWithDuration. For example (using some made up dimensions):

[subMenuView setFrame:CGRectMake(5,-400, 310, 400)];

[UIView animateWithDuration:0.8f
                      delay:0.0f
                    options:UIViewAnimationOptionTransitionCurlDown
                 animations:^{
                     [subMenuView setFrame:CGRectMake(5,0,310,400)];
                 }
                 completion:^ (BOOL finished) 
                 {
                     if (finished) 
                     {
                         //animation has finished, you can do something here, even another nested animation
                     }
                 }];

If you want to then slide it back up, do the opposite...

Upvotes: 1

Related Questions