1

[UIView animateWithDuration:...]ビューのアニメーションシーケンスに使用していUIImageViewます。このような:

[UIView animateWithDuration:1.0 animations:^{
    imageView.frame = newImageRectPosition;
}completion:^(BOOL finished){
 //animate next UIImageView
}];

完了時に「次のUIImageView」をアニメーション化する必要があります。完了時ではなく、前のアニメーションの途中で「次のUIImageView」をアニメーション化する必要があります。そうすることは可能ですか?

4

2 に答える 2

2

2 つの UIView アニメーション ブロックをセットアップできます。1 つは、最初のアニメーションの半分の時間の遅延があります。

[UIView animateWithDuration:1.0 
                 animations:^{ ... }
                 completion:^(BOOL finished){ ... }
];

[UIView animateWithDuration:1.0
                      delay:0.5
                    options:UIViewAnimationCurveLinear
                 animations:^{ ... }
                 completion:^(BOOL finished) { ... }
];
于 2012-10-22T17:14:15.073 に答える
0

目的の効果を得るために使用できる多くのオプションがあります。頭に浮かぶのは、タイマーの使用です。

アニメーションの半分の発火間隔で 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 つ以上のアニメーションを実行する必要がある場合にこれをスケールアップでき、後でアニメーション時間を変更する必要がある場合にすべてをまとめることができます。

于 2012-10-22T17:19:52.517 に答える