我希望能夠使用一個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