2

ユーザーイベントを履歴に保存するアプリがあります。イベントは1つのコントローラーに追加され、別のタブ内のコントローラーに表示されます。

ユーザーが「保存ボタン」をタップすると、イベントが記録されたことを視覚的に確認できるようにしたいと思います。ユーザーにレコードを表示する役割を担うタブバーコントローラーに向かって移動するように、インターフェイス要素をアニメーション化することを考えています。

アニメーション曲線

そのために、インターフェイス要素の1つの中心点をアニメーション化することを考えています。中心点をアニメートする方法は知っていますが、直線でアニメートします。中心点をより「湾曲した」方法でアニメートするにはどうすればよいですか?これを達成する方法はありますか?

CGPoint center = self.ratingReticle.center;

[UIView animateWithDuration:0.6 delay:0 options:UIViewAnimationCurveEaseIn animations:^{
    //move the element offscreen
     self.ratingReticle.center = CGPointMake(260,500);

} completion:^(BOOL finished) {
    //hide the interace element once it is offscreen
    self.ratingReticle.alpha = 0;
    //restore the position of the interface element
    self.ratingReticle.center = center;

    [ UIView animateWithDuration:0.4 animations:^{
        //fade the element back at the original position
        self.ratingReticle.alpha = 1;
    } completion:^(BOOL finished) {

    }];

}];
4

1 に答える 1

5

Core Animation を使用して、 を使用してオブジェクトをベジエ曲線に沿って移動できますCAKeyFrameAnimation

-(void)animate
{
  CAKeyframeAnimation *posAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"];
  posAnim.path = [self bezierPath];
  [image.layer addAnimation:posAnim forKey:@"posAnim"];
}

whereは、ケースに合っbezierPathた a を返します。CGPathRef

于 2012-10-19T19:35:14.260 に答える