pushviewcontroller animation without actually call

2019-05-29 17:43发布

问题:

I would like to animate my view in response to a user action to look like the animation for a pushviewcontroller. That is, I want the view to slide off-screen to the left in response to the user action. However, I don't want to create a new view and push it onto the stack using pushviewcontroller. I want to reuse the same view and reload the data, and I want the reloaded view with the new data to slide in from the right, and it would in the animation for pushviewcontroller. How would you do this?

Thanks for any help!

回答1:

Do this in your viewController. This will move the whole view of it to the right and then after 2 seconds back. You may want to move only a subview so you have some kind of background.

- (void)viewDidAppear:(BOOL)animated
{
    [UIView animateWithDuration:1.2 
                     animations:^{
                         self.view.frame = CGRectMake(320, 0, 320, 480);
                     }];

    [self performSelector:@selector(slideBackView) withObject:nil afterDelay:2.0];
}

- (void)slideBackView
{
    [UIView animateWithDuration:1.2 
                     animations:^{
                         self.view.frame = CGRectMake(0, 0, 320, 480);
                     }];
}


回答2:

you can animate your UIView,See the below SO post ..

iPhone UIView Animation Best Practice

Here is more link ..

http://ameyashetti.wordpress.com/2009/08/17/view-animation-tutorial/