回転にはUIViewAnimationCurveを使用し、位置の変更には別のUIViewAnimationCurveを使用できます。これは可能ですか?同じアニメーションで2つの異なる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
EDIT:(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];
これは素晴らしいアドバイスです.Duncanに感謝します。明日はそれを行こう。 Dave –
こんにちは。私が持っている唯一の質問は、ブロック内で自分のメソッド[self transformPointToViewSpaceFromWorldSpace:self.spriteView.position]を呼び出すことができますか?それは動作し、楽器はどんなリークも表示しませんが、私はブロック内で自己を使うことについて漠然と覚えています。もう一度ありがとう、Dave。 –