2012-06-11 9 views
11

以下のような「簡単で簡単な」方法を実行する方法はありますか?曲線はまだEaseOutを使用しているようです。ios UIViewアニメーションカーブ

[UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; 
[UIView animateWithDuration:0.5 animations:^{ 
    // ... do stuff here 
}]; 

答えて

25

2種類のUIViewアニメーションが混在しています。

[UIView animateWithDuration:0.5 
         delay:0.0 
        options:UIViewAnimationOptionCurveEaseIn 
       animations:^{ 
        // ... do stuff here 
       } completion:NULL]; 

これは、新しいブロックベースのUIViewアニメーションAPIに由来しています。最初の行は、他の一方で、このようになります古いUIViewのアニメーションAPIの一部です:

[UIView beginAnimations:nil context:nil]; 
[UIView setAnimationDuration:0.5]; 
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn]; 
// ... do stuff here 
[UIView commitAnimations]; 

彼らは同じことを行うと、Appleはそれ以来、ブロックベースのAPIを推奨していますけれども、あなたが(どちらかを使用することができますアニメーションが終了した後でコールバックを行う方が簡単/きれいです)。

2

Core Animation、CAKeyFrameAnimationを使用してカーブポイントを定義できます。 http://nachbaur.com/blog/core-animation-part-4

+4

リンクのみの回答はSOにここに落胆していることに注意してください。 [あなたの答えを編集する](http://meta.stackexchange.com/a/8259/186599)とここに概要を追加してください。 – NAZIK

+0

@ NAZIKあなたの名誉私は質問に答えるためにここにいて、querryへの適切な解決策を見つけようとしています! – Steve

+0

私はチュートリアルを終わり、私のupvote – NAZIK

0

隣接ポイントの各ペアの中間点を見つける曲線をp1、p2、p3、p4、p5としましょう。 p1とp2の中間点をm1とします。 m2、m3、m4についても同様です。

  • コントロールポイントとしてp2をポイントm2に追加します。
  • コントロールポイントとしてp3を使用してポイントm3にクワッドカーブを追加します。
  • p4を制御点としてポイントm4にクワッドカーブを追加します。

コード:コードの上

CGFloat screenHeight = self.view.frame.size.height; 
CGFloat screenWidth = self.view.frame.size.width; 

UIView *aniView = [[UIView alloc] initWithFrame:CGRectMake(50, screenHeight, 50, 50)]; 
[aniView setBackgroundColor:[UIColor redColor]]; 
aniView.layer.cornerRadius = 25.0; 
[self.view addSubview:aniView]; 


UIBezierPath *movePath = [UIBezierPath bezierPath]; 
[movePath moveToPoint:aniView.center]; 
[movePath addQuadCurveToPoint:CGPointMake(screenWidth-50,screenHeight-50) 
       controlPoint:CGPointMake(screenWidth/2,screenHeight-150)]; 
CAKeyframeAnimation *moveAnim = [CAKeyframeAnimation animationWithKeyPath:@"position"]; 
moveAnim.path = movePath.CGPath; 
moveAnim.removedOnCompletion = YES; 
CAAnimationGroup *animGroup = [CAAnimationGroup animation]; 
animGroup.animations = [NSArray arrayWithObjects:moveAnim, nil]; 
animGroup.duration = 2.0; 

[CATransaction begin]; { 
    [CATransaction setCompletionBlock:^{ 
     [aniView.layer removeAllAnimations]; 
     [aniView removeFromSuperview]; 
    }]; 

    [aniView.layer addAnimation:animGroup forKey:nil]; 

} [CATransaction commit]; 

コピー過去のいくつかの方法にしてメソッドを呼び出してみてください...

関連する問題