zoukankan      html  css  js  c++  java
  • 更改navigationController push和pop界面切换动画

    http://blog.csdn.net/longlongago2000/article/details/7589706

    作者:longlongago 博客:http://blog.csdn.net/longlongago2000 转帖请保留

    有时候我们需要自定义navigationController push和pop界面切换动画,用到的代码如下:

    For Push:

     

    [cpp] view plaincopy
     
    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];  


    For Pop:

    方法一:

     

    [cpp] view plaincopy
     
    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];  

    方法二:

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

     

    [cpp] view plaincopy
     
    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];  

     

    具体的动画参数请自行更改。

     

     
  • 相关阅读:
    写代码如坐禅:你是哪一类程序员
    开发企业应用系统需要掌握的知识技能(转)
    (转)谈谈多线程的思维方式
    深入理解JavaScript定时机制
    (转)javascritp对fckeditor编辑器操作
    JavaScript异步编程的Promise模式
    (转)jquery调WCF
    (转)《代码大全》学习笔记:第10,11,12,13章 关于变量的使用,命名等
    编程:是一门艺术(转)
    禅修程序员十诫(转)
  • 原文地址:https://www.cnblogs.com/xuejinhui/p/4588630.html
Copyright © 2011-2022 走看看