4

ビュー間の独自の遷移アニメーションを作成しました。位置と変換の 2 つのプロパティをアニメーション化して、ビュー間の立方体のような遷移を提供します。CABasicAnimation変換が「2段階」を使用している間、フレームは使用しCAKeyframeAnimationます。私が理解できないように見える1つの小さな詳細を除いて、すべてが正常に機能します。トランジションCATransform3DScaleでは、中央のキー フレームに を適用して、ズームイン/ズームアウト効果を作成します。アニメーションが少しぎくしゃくしていることを除いて、それはうまくいきます。キー フレーム間を直線的にアニメーション化していますが、それを滑らかにしたいと考えています。CAKeyframeAnimationを使用してそれを行う方法がありますが、変換calculationModeでは機能しないようです。私はそれをに設定しようとしましたがkCAAnimationCubickCAAnimationCubicPaced効果はありませんでした。

以下は、1 つのビューの変換をアニメーション化するコードです (同様のコード ブロックが他のビューをアニメーション化します)。

    CAKeyframeAnimation *aTransform = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
    CATransform3D transform1 = RotateOnX(toView, M_PI_4);
    transform1 = CATransform3DScale(transform1, RotationalZoom, RotationalZoom, RotationalZoom);
    [aTransform setValues:Array([NSValue valueWithCATransform3D:RotateOnX(toView, M_PI_2)],
                                [NSValue valueWithCATransform3D:transform1],
                                [NSValue valueWithCATransform3D:RotateOnX(toView, 0)])];
    [toView.layer addAnimation:aTransform forKey:@"transform"];

注:RotateOnX(UIView *, CGFloat)は、目的のラジアンによって X 軸上で回転されたビューの変換を返すブロックです。

ご覧のとおり、中央のキー フレームにのみスケーリング変換を設定しています。また、ビューの回転は完全にスムーズです。方向が変わるときに「急に」見えるのはスケーリングだけです。

スケーリング/ズームをスムーズにする方法について誰かアイデアがありますか?

4

1 に答える 1

3

Try the timingFunctions property. Since you have 3 keyframes, you need 2 timing functions: one for the animation from keyframe 0 to keyframe 1, and another for the animation from keyframe 1 to keyframe 2.

aTransform.timingFunctions = [NSArray arrayWithObjects:
    [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInOut],
    [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInOut],
    nil];
于 2012-07-20T21:21:35.617 に答える