Can I “curl down” a page on popViewControllerAnima

2019-05-18 14:09发布

问题:

I can "curl up" a view controller with this code:

[UIView beginAnimations:@"animation" context:nil];
[self.navigationController pushViewController:page animated:NO];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:NO]; 
[UIView commitAnimations];

but I can't curl down the last page like this:

[UIView beginAnimations:@"animation" context:nil];
[self.navigationController popViewControllerAnimated:NO];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.navigationController.view cache:NO]; 
[UIView commitAnimations];

any idea why not? I just really want to "reverse" the animation (as if a sticker has been peeled off to show the 'push'ed view controller and stuck back on when they click a button).

Thanks

回答1:

Ok, my old answer was totally wrong... the problem is that you are popping the view controller before setting the transition view. If you change the code to this:

[UIView beginAnimations:@"animation" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.navigationController.view cache:NO]; 
[self.navigationController popViewControllerAnimated:NO];
[UIView commitAnimations];

it works fine



回答2:

Using OpenGL or a lot of complex CoreAnimation processes, I am sure that you could, but, It would be a lot of hassle for doing something like that. Something that might help you along: A simple book turning application written entirely with CoreAnimation