zoukankan      html  css  js  c++  java
  • 动画,组合动画。

    1.     设置位置

          然后

     [UIView animateWithDuration:0.5 animations:^{

                [self.view layoutIfNeeded]; // 写了这个才会执行动画

            }];

     

    2.  转圆 加载中 动画

      CABasicAnimation* rotationAnimation;

        rotationAnimation               = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];

        rotationAnimation.toValue       = [NSNumber numberWithFloat: M_PI * 2.0 ];

        rotationAnimation.duration      = 1;

        rotationAnimation.cumulative    = YES;

        rotationAnimation.repeatCount   = MAXFLOAT;

        

        [self.circleImgV.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];

     

    3.  

     

      [CATransaction begin];

        [CATransaction begin];

        [CATransaction setAnimationDuration:2];

        myLayer.frame = CGRectMake(50, 50, 200, 200);

        [CATransaction commit];

        [CATransaction setAnimationDuration:2];

        myLayer.backgroundColor = [UIColor blueColor].CGColor;

        [CATransaction commit];

    3.  /*****高级动画*****/

     

    -(void)transition

    {

    /*

        CATransition *atr = [CATransition animation];

        atr.type = @"rippleEffect";

        atr.duration = 2;

    //设置为YES  会使得动画的视图返回到初始值

        atr.autoreverses = YES;

        [myLayer addAnimation:atr forKey:@"ripple"];

    */

     

    //关键帧动画

        /*

        CAKeyframeAnimation *anmation = [CAKeyframeAnimation animationWithKeyPath:@"backgroundColor"];

        anmation.values = @[(id)[UIColor redColor].CGColor,(id)[UIColor yellowColor].CGColor,(id)[UIColor blueColor].CGColor,(id)[UIColor  greenColor].CGColor];

        anmation.duration = 2;

        //设置为YES  会使得动画的视图返回到初始值

        anmation.autoreverses = YES;

        [myLayer addAnimation:anmation forKey:@"backGroudColor"];

    */

     

        //组合动画

        CABasicAnimation *anmiation = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];

        anmiation.duration = 5;

        anmiation.autoreverses = YES;

        anmiation.fromValue = (id)myLayer.backgroundColor;

        anmiation.toValue = (id)[UIColor redColor].CGColor;

     

        CABasicAnimation *anmiationTwo = [CABasicAnimation  animationWithKeyPath:@"position"];

        anmiationTwo.duration = 2;

        anmiationTwo.autoreverses = YES;

     

        anmiationTwo.fromValue = [NSValue valueWithCGPoint:myLayer.position];

       CGPoint point = myLayer.position;

        point.y += 100;

        anmiationTwo.toValue = [NSValue valueWithCGPoint:point];

     

        CAAnimationGroup *group = [CAAnimationGroup animation];

        group.duration = 5;

        group.autoreverses = YES;

        group.animations = @[anmiation,anmiationTwo];

        [myLayer addAnimation:group forKey:nil];

    }

  • 相关阅读:
    关于中间件(Middleware)的理解
    强类型约束的中间件(IMiddleware)
    常规中间件(Conventional Middleware) 之 自定义中间件
    常规中间件(Conventional Middleware) 之 内联中间件(in-line middleware)
    git 遴选(cherry-pick)
    sql转linq
    python知识体系
    when 的使用
    关于联表查询时NULL值的处理
    $project 选择要显示的字段
  • 原文地址:https://www.cnblogs.com/shifu/p/5749348.html
Copyright © 2011-2022 走看看