欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

动画组合

程序员文章站 2022-03-02 19:44:43
...
  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; //保持最新状态
    
    [email protected][zoomanimation,moveanimation];
    group.duration=5.0;
    group.removedOnCompletion=YES;
    [luckview.layer addAnimation:group forKey:nil];