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
    */
  • 相关阅读:
    对double数据类型的数据保留两位小数,并且进行四舍五入
    div位置设置
    每天一算法 -- (排序算法总结)
    SQL行转列
    设计模式的六大原则
    每天一算法 -- (插入排序)
    每天一算法 -- (选择排序)
    通用扩展函数--类型转换
    wcf和webservice
    Cookie的介绍及使用
  • 原文地址:https://www.cnblogs.com/yipingios/p/4505673.html
Copyright © 2011-2022 走看看