我希望能够使用一个 UIViewAnimationCurve 进行旋转,另一个用于位置变化。这可能吗?
例如(在伪代码中);
// Begin animations
// Set rotation animation curve to EaseInOut
// Set position animation curve to Linear
// Make some changes to position
// Make some change to the angle of rotation
// Commit the animations
编辑:(下面建议的 CAAnimationGroup 方法) - 创建了 2 个单独的 CABasicAnimations 和一个 CAAnimationGroup 但是动画没有开始。有任何想法吗?
CABasicAnimation *postionAnimation = [CABasicAnimation animationWithKeyPath:@"position"];
postionAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
postionAnimation.toValue = [NSValue valueWithCGPoint:[self transformPointToWorldSpaceFromViewSpace:self.spriteView.position]];
postionAnimation.delegate = self;
CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.z"];
rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
rotationAnimation.toValue = [NSNumber numberWithFloat:self.spriteView.angle -= M_PI_2];
rotationAnimation.delegate = self;
CAAnimationGroup *animationsGroup = [CAAnimationGroup animation];
animationsGroup.duration = self.clockSpeed;
animationsGroup.animations = [NSArray arrayWithObjects:postionAnimation, rotationAnimation, nil];
// Perform the animation
[self.spriteView.layer addAnimation:animationsGroup forKey:nil];