Joh*_*ohn 51
这样的事情应该有效
[UIView beginAnimations:@"animation" context:nil];
[self.navigationController pushViewController: yourviewcontroller animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)
不要忘记在调用pushViewController时将动画设置为NO
iKT*_*iKT 15
这也适用于.. iOS 4.0 and greater
[UIView transitionWithView:self.navigationController.view duration:0.8 options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^(void) {
BOOL oldState = [UIView areAnimationsEnabled];
[UIView setAnimationsEnabled:NO];
[self.navigationController pushViewController:viewController animated:YES];
[UIView setAnimationsEnabled:oldState];
}
completion:nil];
Run Code Online (Sandbox Code Playgroud)
小智 5
- (void)viewWillDisappear:(BOOL)animated {
[UIView beginAnimations:@"animation2" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration: 0.7];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations]; }
Run Code Online (Sandbox Code Playgroud)
在新的viewcontroller中,当按下工具栏中的后退按钮时,它会以相同的方式向后翻转(而不是向左滑动) - 确保在此处启用动画,例如,如果您使用自定义按钮弹出堆栈,请使用:
- (void) backToPrevious: (id) sender
{
//[self.navigationController popViewControllerAnimated:YES];
[self dismissModalViewControllerAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud)
对于模态呈现的视图控制器,您可以使用属性更改动画modalTransitionStyle
。AFAIK,没有办法改变导航控制器的推送动画(除了从头开始重建 UINavigationController )。