• 之三:CAAnimationGroup


    动画组顾名思义就是将多个不同的动画效果组合起来同时作用于一个层上

    代码演示:

     1 // 创建基本路径
     2 CGMutablePathRef path = CGPathCreateMutable();
     3 
     4 // 设置路径的起点
     5 CGPathMoveToPoint(path, NULL, 50.0, 120.0);
     6 
     7 //添加4条曲线路径到path中
     8 CGPathAddCurveToPoint(path, NULL, 50.0, 275.0, 150.0, 275.0, 150.0, 120.0);
     9 CGPathAddCurveToPoint(path,NULL,150.0,275.0,250.0,275.0,250.0,120.0);
    10 CGPathAddCurveToPoint(path,NULL,250.0,275.0,350.0,275.0,350.0,120.0);
    11 CGPathAddCurveToPoint(path,NULL,350.0,275.0,450.0,275.0,450.0,120.0);
    12 
    13 //使用关键字"position"创建关键帧动画
    14 CAKeyframeAnimation * posAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    15 
    16 posAnim.path = movePath.CGPath;
    17     
    18 //缩放动画
    19 CABasicAnimation *scaleAnim = [CABasicAnimation animationWithKeyPath:@"transform"];
    20 
    21 scaleAnim.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
    22 
    23 scaleAnim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)];
    24     
    25 //透明动画
    26 CABasicAnimation *opacityAnim = [CABasicAnimation animationWithKeyPath:@"alpha"];
    27     
    28 opacityAnim.fromValue = [NSNumber numberWithFloat:1.0];
    29 
    30 opacityAnim.toValue = [NSNumber numberWithFloat:0.1];
    31     
    32 //动画组
    33 CAAnimationGroup *animGroup = [CAAnimationGroup animation];
    34     
    35 animGroup.animations = [NSArray arrayWithObjects:posAnim, scaleAnim, opacityAnim, nil];
    36 
    37 animGroup.duration = 1;
    38 
    39 // 动画完成后保持最新状态
    40 animGroup.removedOnCompletion = NO;
    41 animGroup.fillMode = kCAFillModeForwards;
    42     
    43 [_myView.layer addAnimation:animGroup forKey:nil];
  • 相关阅读:
    Cassandra 分布式集群
    BI Project Managerment
    再学TSQL基础--单表查询
    pig 介绍与pig版 hello world
    xml in hadoop ETL with pig summary
    Mongodb--gridfs与分片实验
    定位frame 中的对象
    层级定位
    定位一组对象-checkbox 、radiobutton
    设置等待时间
  • 原文地址:https://www.cnblogs.com/xs514521/p/5198369.html
Copyright © 2020-2023  润新知