目的の効果を得るために使用できる多くのオプションがあります。頭に浮かぶのは、タイマーの使用です。
アニメーションの半分の発火間隔で NSTimer を使用し、タイマーに別のアニメーションを発火させます。2 つのアニメーションが互いに干渉しない限り、問題はありません。
例は次のようになります。
NSTimer* timer;
// Modify to your uses if so required (i.e. repeating, more than 2 animations etc...)
timer = [NSTimer scheduledTimerWithTimeInterval:animationTime/2 target:self selector:@selector(runAnimation) userInfo:nil repeats:NO];
[UIView animateWithDuration:animationTime animations:^{
imageView.frame = newImageRectPosition;
} completion:nil];
- (void)runAnimation
{
// 2nd animation required
[UIView animateWithDuration:animationTime animations:^{
imageView.frame = newImageRectPosition;
} completion:nil];
}
タイマーを使用すると、2 つ以上のアニメーションを実行する必要がある場合にこれをスケールアップでき、後でアニメーション時間を変更する必要がある場合にすべてをまとめることができます。