我的CAAnimationGroup运行速度太快。我希望它总共需要花费50秒才能完成某项任务,并且它在大约3秒内完成...它会在第一个动画中轻松过度,而另一个动画则会变慢。
hover = [CABasicAnimation animationWithKeyPath:@"position"];
hover.fillMode = kCAFillModeForwards;
hover.removedOnCompletion = NO;
hover.additive = YES; // fromValue and toValue will be relative instead of absolute values
hover.fromValue = [NSValue valueWithCGPoint:CGPointZero];
hover.toValue = [NSValue valueWithCGPoint:CGPointMake(26*22, 26*-10.0)]; // y increases downwards on iOS
hover.autoreverses = FALSE; // Animate back to normal afterwards
hover.repeatCount = 0; // The number of times the animation should repeat
CABasicAnimation *fall = [CABasicAnimation animationWithKeyPath:@"position"];
fall.fillMode = kCAFillModeForwards;
fall.removedOnCompletion = NO;
fall.additive = YES; // fromValue and toValue will be relative instead of absolute values
fall.fromValue = [NSValue valueWithCGPoint:CGPointMake(26*22, 26*-10.0)];
fall.toValue = [NSValue valueWithCGPoint:CGPointMake(26*22, guess1*700.0)]; // y increases downwards on iOS
fall.autoreverses = FALSE; // Animate back to normal afterwards
fall.repeatCount = 0; // The number of times the animation should repeat
CAAnimationGroup* group = [CAAnimationGroup new];
group.beginTime = 0.;
[group setDuration:50.0];
group.animations = @[ hover, fall ];
[theDude.layer addAnimation:group forKey:@"myHoverAnimation"];
答案 0 :(得分:-1)
根据您的实施情况,我假设您希望sequence
对象theDude
属性上的position
动画。
您可以使用CATransaction
使用它的完成功能块来实现动画。更多内容可以阅读here。