动画组合

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

你可能感兴趣的:(动画组合)