2012-05-11 7 views
0

私は現在、要素のサイズ変更/移動のためにいくつかのコアアニメーションを実装するプロジェクトに取り組んでいます。多くのMacでは、これらのアニメーションでフレームレートが大幅に低下していることがわかりましたが、かなり単純です。コアアニメーション:フレームレート

// Set some additional attributes for the animation. 
    [theAnim setDuration:0.25]; // Time 
    [theAnim setFrameRate:0.0]; 
    [theAnim setAnimationCurve:NSAnimationEaseInOut]; 

    // Run the animation. 
    [theAnim startAnimation]; 
    [self performSelector:@selector(endAnimation) withObject:self afterDelay:0.25]; 

が明示的にフレームレートを述べない(たとえば60.0、代わりに0.0でそれを残す)などのスレッドでより多くの優先順位をつけ、その可能性のフレームレートを上げる:ここでは例ですか?これらをまとめてアニメーション化するより良い方法はありますか?

答えて

6

The documentation for NSAnimationは0.0手段のフレームレートは可能な限り速く行くために

を言う... フレームレートは、できるだけ

として高速に保証されていない、合理的であるべきです60 fpsと同じです。 Core Animationの代わりにNSAnimationの

NSAnimationを使用して


は本当にCore Animationの(のAppKitのそのパット)の一部ではありません。代わりに、アニメーションのCore Animationを試してみることをおすすめします。あなたは のようなアニメーション何かのためのCore Animationに
  • スイッチをアニメーション化されているビューにYESへ- (void)setWantsLayer:(BOOL)flagの設定ファイルでインポートするプロジェクトに
  • をQuartzCore.frameworkの追加

    1. 上のアニメーションの長さから「

      」を選択すると、「暗黙のアニメーション」(レイヤのプロパティを変更するだけ)のように見えます。場合は、しかし、あなたは、このような何かを明示的なアニメーションを使用することができ、より制御したい:

      CABasicAnimation * moveAnimation = [CABasicAnimation animationWithKeyPath:@"frame"]; 
      [moveAnimation setDuration:0.25]; 
      // There is no frame rate in Core Animation 
      [moveAnimation setTimingFunction:[CAMediaTimingFunction funtionWithName: kCAMediaTimingFunctionEaseInEaseOut]]; 
      [moveAnimation setFromValue:[NSValue valueWithCGRect:yourOldFrame]] 
      [moveAnimation setToValue:[NSValue valueWithCGRect:yourNewFrame]]; 
      
      // To do stuff when the animation finishes, become the delegate (there is no protocol) 
      [moveAnimation setDelegate:self]; 
      
      // Core Animation only animates (not changes the value so it needs to be set as well) 
      [theViewYouAreAnimating setFrame:yourNewFrame]; 
      
      // Add the animation to the layer that you 
      [[theViewYouAreAnimating layer] addAnimation:moveAnimation forKey:@"myMoveAnimation"]; 
      

      その後のコールバックのために、あなたは

      - (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)isFinished { 
          // Check the animation and perform whatever you want here 
          // if isFinished then the animation completed, otherwise it 
          // was cancelled. 
      } 
      
  • +0

    恐ろしいを実装!ダビデのおかげで大きな感謝 - これを実装した後のパフォーマンスはNSAnimationに匹敵しません。はるかに速く – Zakman411

    関連する問題