我希望能够使用一个UIViewAnimationCurve进行旋转,而另一个用于更改位置。这可能吗?在同一个动画中使用两个不同的UIViewAnimationCurves
例如(在伪代码中);
// 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];
这是很好的建议,谢谢邓肯。明天会放弃它。戴夫 – 2012-07-14 18:40:32
嗨邓肯,做到这一点,并工作的一种享受!我唯一的问题是,可以在块中调用我的方法[self transform.ToViewSpaceFromWorldSpace:self.spriteView.position]吗?它的工作原理和仪器没有显示任何泄漏,但我隐约记得有关在块内使用自己的东西。再次感谢戴夫。 – 2012-07-16 07:54:48