更改navigationController pu…

来源:互联网 发布:会计软件下载 编辑:程序博客网 时间:2024/04/24 00:13

自定义navigationController pushpop界面切换动画,代码如下:

 Push:

 

  1. MainView *nextView=[[MainView alloc] init];  
  2. [UIView  beginAnimations:nil context:NULL];  
  3. [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];  
  4. [UIView setAnimationDuration:0.75];  
  5. [self.navigationController pushViewController:nextView animated:NO];  
  6. [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];  
  7. [UIView commitAnimations];  
  8. [nextView release]; 
  9.  Pop:

 

方法一:

  1. [UIView  beginAnimations:nil context:NULL];  
  2. [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];  
  3. [UIView setAnimationDuration:0.75];  
  4. [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];  
  5. [UIView commitAnimations];  
  6.   
  7. [UIView beginAnimations:nil context:NULL];  
  8. [UIView setAnimationDelay:0.375];  
  9. [self.navigationController popViewControllerAnimated:NO];  
  10. [UIView commitAnimations];  

方法二:

可实现左右滑动动画,可设置滑动方向。

  1. CATransition* transition [CATransition animation];  
  2. transition.duration 0.5;  
  3. transition.timingFunction [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];  
  4. transition.type kCATransitionFade; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade  
  5. //transition.subtype kCATransitionFromTop; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom  
  6. [self.navigationController.view.layer addAnimation:transition forKey:nil];  
  7. [[self navigationController] popViewControllerAnimated:NO]; 
0 0
原创粉丝点击