美文网首页
动画组合

动画组合

作者: 赤焰军少帅林殊 | 来源:发表于2018-05-22 11:47 被阅读16次
      CAAnimationGroup *group=[CAAnimationGroup animation];
        CABasicAnimation *moveanimation = [CABasicAnimation animationWithKeyPath:@"transform.translation.y"];///.y的话就向下移动。
        moveanimation.toValue = [NSNumber numberWithInt:-60];
        moveanimation.removedOnCompletion = YES;//yes的话,又返回原位置了。
        moveanimation.repeatCount =1;
     
        
        CAKeyframeAnimation *zoomanimation = [CAKeyframeAnimation animation];
        zoomanimation.keyPath = @"transform";
        NSMutableArray *values = [NSMutableArray array];
        [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.5, 0.5, 1.0)]];
        [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1, 1, 1.0)]];
        [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.5, 0.5, 1.0)]];
         zoomanimation.keyTimes = @[@(0.1), @(0.8), @(1.0)]; //每一帧用的时间比
        [zoomanimation setValues:values];//设置变动的值
        zoomanimation.autoreverses=YES;//不重复
        zoomanimation.repeatCount=1;//重复次数
    //    zoomanimation.removedOnCompletion = NO; //执行动画后不要移除
    //    zoomanimation.fillMode = kCAFillModeForwards; //保持最新状态
        
        group.animations=@[zoomanimation,moveanimation];
        group.duration=5.0;
        group.removedOnCompletion=YES;
        [luckview.layer addAnimation:group forKey:nil];
    

    相关文章

      网友评论

          本文标题:动画组合

          本文链接:https://www.haomeiwen.com/subject/ftshjftx.html