2

私は2つのUIButtonを持っています:

UIButton *製品 UIButton *次の製品

商品に関して各ボタンに画像を設定しております。

1 つのボタンがフェードインし、2 つ目のボタンがフェードアウトするようにボタンをアニメーション化したいと考えています。

親切に私を助けて

4

2 に答える 2

1

代わりに新しいブロックAPIを使用します。最初の答えで、アニメーション中にユーザーがコントロールを操作できるかどうかはわかりません。私も同様のケースがあり、以下のコードを使用しました。重要なのはオプションです:UIViewAnimationOptionAllowUserInteraction

[UIView animateWithDuration:0.5f 
                      delay:0.0f
                    options:UIViewAnimationOptionAllowUserInteraction 
                 animations:^(void) {
    [product setAlpha:0.0f];
    [nextProduct setAlpha:1.0f];

} completion:^(BOOL finished) {
    //Maybe set the new alpha here when the first animation is done?
}];
于 2012-05-15T12:26:12.680 に答える
0

UIView beginAnimationsと の間でアニメーション化する変更をラップしますUIView commitAnimations

[UIView beginAnimations:nil context:nil];

product.alpha = 0;
nextProduct.alpha = 1;

[UIView commitAnimations];

タイミングと外観をカスタマイズする方法については、UIView のドキュメントを確認してください。

于 2012-05-15T12:16:30.110 に答える