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];

    }

  • 相关阅读:
    uCOS的软件定时器、uCOS时钟节拍和滴答定时器的关系
    学习ucosii要用到的几本书
    freertos知识点笔记——队列、二值信号量、计数信号量
    《嵌入式软件设计基础——基于ARM Cortex—M3》读书笔记
    大小端测试C实现
    static 的三个作用
    基于IAR6或者IAR7建立STM32开发工程(通过实际测试,使用IAR6.30.4)
    STM32中stm32f0xx_flash.icf文件的作用详解!(不错的!)
    CRC点滴
    int *a[] 与(int *)a【5】的区别
  • 原文地址:https://www.cnblogs.com/shifu/p/5749348.html
Copyright © 2011-2022 走看看