zoukankan      html  css  js  c++  java
  • 【代码笔记】iOS-Transition动画

    一,工程图。

    二,代码。

    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.
    }
    复制代码
  • 相关阅读:
    web自动化测试-D2-学习笔记之二(HTML基础之JS)
    web自动化测试-D2-学习笔记之一(HTML基础之DOM操作)
    web自动化测试-D1-学习笔记之一(HTML 和 CSS基础)
    Selenium-常问面试题
    python自动化测试-D11-学习笔记之一(yaml文件,ddt)
    python习题:封装一个日志模块
    python自动化测试-D10-学习笔记之二(Python–logging模块)
    python习题:unittest参数化-数据从文件或excel中读取
    python自动化测试-D10-学习笔记之一(unittest参数化)
    python自动化测试-D9-学习笔记之二(异常处理)
  • 原文地址:https://www.cnblogs.com/yang-guang-girl/p/7015731.html
Copyright © 2011-2022 走看看