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

    }

  • 相关阅读:
    图论03—随意两点间最短距离及路径(改进)
    <转>Openstack ceilometer 宿主机监控模块扩展
    【从零学习openCV】IOS7下的openCV开发起步(Xcode5.1.1&openCV2.49)
    零基础学python-6.2 共享引用
    hdu 2191 悼念512汶川大地震遇难同胞——珍惜如今,感恩生活
    Android与设计模式——单例(Singleton)模式
    SpringMVC+Jquery -页面异步载入数据
    hdoj Let the Balloon Rise
    openStack使用宿主机监控
    winscp自动执行脚本
  • 原文地址:https://www.cnblogs.com/shifu/p/5749348.html
Copyright © 2011-2022 走看看