zoukankan      html  css  js  c++  java
  • 核心动画04-CATransition转场动画

    Transition:过度,执行一些过度动画,比如两个界面切换的时候,push就是一种过度动画

    模拟翻书效果:通过按钮模拟左右滑动,index标记当前的图片的下标名

    #pragma make 上一张
    - (IBAction)previous:(UIButton *)sender {
        
        self.index--;
        if (self.index == -1) {
            self.index = 8;
        }
        
        self.iconView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpg",self.index + 1]];
        
        //转场动画
        CATransition *anim = [CATransition animation];
    //    anim.type = @"cube";  // 动画过渡类型
    //    动画的方向,枚举类型,四种方向
    //    anim.subtype = kCATransitionFromLeft;  // 动画过渡方向
        
        anim.type = @"pageUnCurl";
        anim.duration = 0.5;  // 动画持续1s
        
        //动画加到哪个layer上面
        [self.iconView.layer addAnimation:anim forKey:nil];
    }
    
    #pragma make 下一张
    - (IBAction)next:(id)sender {
        
        self.index++;
        if (self.index == 9) {
            self.index = 0;
        }
        
        self.iconView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpg",self.index + 1]];
        
        //转场动画
        CATransition *anim = [CATransition animation];
        anim.type = @"pageCurl";
        anim.duration = 0.5;
        
        //从百分之多少开始动画
        anim.startProgress = 0.5;
        
        //从百分之多少结束动画
        anim.endProgress = 0.8;
        
        // 代理,动画执行完毕后会调用delegate的animationDidStop:finished:
    //    anim.delegate = self;
        
        [self.iconView.layer addAnimation:anim forKey:nil];
    }

    过度效果和过度方向例举

    /* 过渡效果 
    fade     //交叉淡化过渡(不支持过渡方向) kCATransitionFade  
    push     //新视图把旧视图推出去 kCATransitionPush  moveIn   //新视图移到旧视图上面 kCATransitionMoveIn  
    reveal   //将旧视图移开,显示下面的新视图 kCATransitionReveal  
    cube     //立方体翻滚效果  
    oglFlip  //上下左右翻转效果  
    suckEffect   //收缩效果,如一块布被抽走(不支持过渡方向)  
    rippleEffect //滴水效果(不支持过渡方向)  
    pageCurl     //向上翻页效果  
    pageUnCurl   //向下翻页效果  
    cameraIrisHollowOpen  //相机镜头打开效果(不支持过渡方向)  
    cameraIrisHollowClose //相机镜头关上效果(不支持过渡方向)
    */    

    /* 过渡方向
     kCATransitionFromRight  
    kCATransitionFromLeft  
    kCATransitionFromBottom  
    kCATransitionFromTop
    */
  • 相关阅读:
    禁止 git 自动转换换行符
    一个单元测试问题的解决
    关于脏读、幻象读、不可重复读的理解
    PKCS7 的 attached 和 detached 方式的数字签名
    关于DES加密中的 DESede/CBC/PKCS5Padding
    解决grep的结果无法显示文件名的问题
    解决64位操作系统下运行psql的问题
    一个用于将sql脚本转换成实体类的js代码
    批量将代码中的 get_XXX 替换成 XXX
    关于数据库中密码的存储
  • 原文地址:https://www.cnblogs.com/yipingios/p/4505673.html
Copyright © 2011-2022 走看看