0

ボタンを0の幅に縮小するこの単純なアニメーションをコミットしています。

[UIView animateWithDuration:0.2
                 delay: 0.0
                 options: UIViewAnimationOptionCurveEaseIn
                 animations:^{
                     [btnActionButton setFrame:CGRectMake(160, 10, 0, 55)];
                 }
                 completion:^(BOOL finished){
                 }];

問題は、アニメーションが開始されると、ボタンのtitleLabelが自動的に非表示になることです...シミュレータのslowAnimationモードを使用して確認しました。

ボタンのタイトルが最初に消えるとかなり厄介に見えるので、アニメーション中にラベルもフレームとともに縮小する可能性はありますか?

前もって感謝します。オベイド

4

3 に答える 3

3

これは、幅 0 によるものです。

以下のコードを使用します。

[UIView animateWithDuration:0.2
             delay: 0.0
             options: UIViewAnimationOptionCurveEaseIn
             animations:^{
                 [btnActionButton setFrame:CGRectMake(160, 10, 50, 55)];
             }
             completion:^(BOOL finished){
             }];

50 の代わりに、アニメーション後のボタンの幅を指定します。

于 2012-07-11T09:13:48.487 に答える
1
          [UIView animateWithDuration:0.2
                      delay: 0.0
                    options: UIViewAnimationOptionCurveEaseIn
                 animations:^{
                     [btnActionButton.titleLabel setCenter:CGPointMake(-64, btnActionButton.titleLabel.center.y)];
                     [btnDeleteButton setFrame:CGRectMake(160, 10, 128, 55)];
                 }
                 completion:^(BOOL finished){
                     [btnActionButton setFrame:CGRectMake(160, 10, 0, 55)];
                     [btnActionButton.titleLabel setCenter:CGPointMake(0, btnActionButton.titleLabel.center.y)];
                 }];

こんな感じでうまくいきました… 実は、最初のボタンを非表示にして、2番目のボタンをスライド式に表示させたかったのです。

于 2012-07-11T09:36:20.220 に答える
0

ラベルもアニメーション化してみてください。私はこのように意味します:

[UIView animateWithDuration:0.2
             delay: 0.0
             options: UIViewAnimationOptionCurveEaseIn
             animations:^{
                 [btnActionButton setFrame:CGRectMake(160, 10, 0, 55)];
                 [btnActionButton.titleLabel setFrame:CGRectMake(  0,  0, 0, 55)];
             }
             completion:^(BOOL finished){
             }];

お役に立てれば。

乾杯!

于 2012-07-11T08:57:37.083 に答える