一,工程图。

二,代码。

RootViewController.h

#import <UIKit/UIKit.h>

@interface RootViewController : UIViewController

@end

 

RootViewController.m

复制代码
#import "RootViewController.h"
#import "FirstViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    self.title=@"首页";
    self.view.backgroundColor=[UIColor redColor];
    
    
    /* 过渡效果
     fade     //交叉淡化过渡(不支持过渡方向)
     push     //新视图把旧视图推出去
     moveIn   //新视图移到旧视图上面
     reveal   //将旧视图移开,显示下面的新视图
     cube     //立方体翻滚效果
     oglFlip  //上下左右翻转效果
     suckEffect   //收缩效果,如一块布被抽走(不支持过渡方向)
     rippleEffect //滴水效果(不支持过渡方向)
     pageCurl     //向上翻页效果
     pageUnCurl   //向下翻页效果
     cameraIrisHollowOpen  //相机镜头打开效果(不支持过渡方向)
     cameraIrisHollowClose //相机镜头关上效果(不支持过渡方向)
     */
    
    /* 过渡方向
     fromRight;
     fromLeft;
     fromTop;
     fromBottom;
     */
    
    
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
   
    
    CATransition *transition = [CATransition animation];
    // 动画时间控制
    transition.duration = 0.3f;
    //动画的开始与结束的快慢
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    //是否代理
    transition.delegate = self;
    //此动画执行完后会自动remove,默认值为true
    transition.removedOnCompletion = NO;
    //各种动画效果
    transition.type = kCATransitionMoveIn;
    //动画方向
    transition.subtype = kCATransitionFromTop;
    
    FirstViewController *viewCon = [[FirstViewController alloc]init];
    
    [self.navigationController pushViewController:viewCon animated:NO];
    
    // 想添加CA动画的VIEW的层上添加此代码
    [self.navigationController.view.layer addAnimation:transition forKey:nil];

}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
复制代码
内容来源于网络如有侵权请私信删除
你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!