NSAnimation のドキュメントには、
フレーム レート 0.0 は、できるだけ速く進むことを意味します。フレーム レートは保証されません。
合理的に、可能な限り高速は 60 fps と同じにする必要があります。
NSAnimation の代わりにコア アニメーションを使用する
NSAnimation は実際には Core Animation の一部ではありません (AppKit の一部です)。代わりに、アニメーションに Core Animation を試すことをお勧めします。
- プロジェクトに QuartzCore.framework を追加する
- ファイルへのインポート
- (void)setWantsLayer:(BOOL)flag
アニメートしているビューで YES に設定する
- 次のようなアニメーションの Core Animation に切り替えます
上記のアニメーションの長さから、「暗黙のアニメーション」(レイヤーのプロパティを変更するだけ)が最適なようです。ただし、より詳細な制御が必要な場合は、次のような明示的なアニメーションを使用できます。
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.
}