zoukankan      html  css  js  c++  java
  • iOS CoreAnimation(核心动画二)

    CATransition :转场动画  翻转动画

    @interface ViewController ()
    - (IBAction)previous:(UIButton *)sender;
    
    - (IBAction)next:(UIButton *)sender;
    
    @property (strong, nonatomic) IBOutlet UIImageView *iconView;
    
    @property(nonatomic,assign)int index;//当前图片的索引
    
    @property (strong, nonatomic) IBOutlet UIView *myView;
    
    
    
    @end
    

     /* 过渡效果  

    fade     //交叉淡化过渡(不支持过渡方向) kCATransitionFade  

    push     //新视图把旧视图推出去  kCATransitionPush
    moveIn   //新视图移到旧视图上面   kCATransitionMoveIn

    reveal   //将旧视图移开,显示下面的新视图  kCATransitionReveal  

    cube     //立方体翻滚效果  

    oglFlip  //上下左右翻转效果  

    suckEffect   //收缩效果,如一块布被抽走(不支持过渡方向)  

    rippleEffect //滴水效果(不支持过渡方向)  

    pageCurl     //向上翻页效果  

    pageUnCurl   //向下翻页效果  

    cameraIrisHollowOpen  //相机镜头打开效果(不支持过渡方向)  

    cameraIrisHollowClose //相机镜头关上效果(不支持过渡方向)

    */

    //下一页

    - (IBAction)next:(UIButton *)sender {
        
        self.index++;
        
        if (self.index==9) {
            
            self.index=0;
        }
        
        
        NSString * filename=[NSString stringWithFormat:@"%d.jpg",self.index+1];
        self.iconView.image=[UIImage imageNamed:filename];
        
        //转场动画
        CATransition * anim=[CATransition animation];
        
        //翻转的类型
        anim.type=@"pageCurl";
    //翻转方向 // anim.subtype=kCATransitionFromRight; //从多少进度开始翻 anim.startProgress=0.3; //到多少进度结束 anim.endProgress=0.5; [self.iconView.layer addAnimation:anim forKey:nil]; }

    上一页

    - (IBAction)previous:(UIButton *)sender {
        self.index--;
        if (self.index==-1) {
            self.index=8;
        }
        NSString * filename=[NSString stringWithFormat:@"%d.jpg",self.index+1];
        self.iconView.image=[UIImage imageNamed:filename];
        //转场动画
        CATransition * anim=[CATransition animation];
        
        //翻转的类型
        anim.type=@"pageUnCurl";
        
        //翻转方向
    //    anim.subtype=kCATransitionFromLeft;
        
        [self.iconView.layer addAnimation:anim forKey:nil];
        
    }
    

    CAAnimationGroup:组合动画

    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
        
        //创建旋转动画对象
        CABasicAnimation * rotate =[CABasicAnimation animation];
        rotate.keyPath=@"transform.rotation";
        rotate.toValue=@(M_PI);
    
        
        //创建缩放动画对象
        CABasicAnimation * scale=[CABasicAnimation animation];
        scale.keyPath=@"transform.scale";
        scale.toValue=@(0.0);
       
        
        //添加动画
        CAAnimationGroup * group =[CAAnimationGroup animation];
        group.duration=2.0;
        group.removedOnCompletion=NO;
        group.fillMode=kCAFillModeForwards;
        group.repeatCount=MAX_CANON;
        group.animations=@[scale];
        group.animations=@[rotate,scale];
        [self.myView.layer addAnimation:group forKey:nil];
        
    }
    
  • 相关阅读:
    (转载)Hadoop示例程序WordCount详解
    Eclipse打不开,闪退
    【python】实例-把两个无规则的序列连接成一个序列,并删除重复的元素,新序列按照升序排序
    【python】格式化输出
    【python】序列、元组、集合、字典和range函数
    【python】实例-判断用户输入数字的类型
    【python】文件操作
    python 异常类型----后期需理解调整
    【python】OOP编程----类的定义及封装
    【python】if&&for&&while语句
  • 原文地址:https://www.cnblogs.com/wangbinbin/p/4795879.html
Copyright © 2011-2022 走看看