0

_menuButtonのtouchUpInside呼び出しで、アニメーションを実行して、メニューのラベルを「開く」から「閉じる」に変更するための完了ブロックを含むメニューを表示します。そのアニメーションは正常に機能しますが、_menuButtonを押すと、ユーザーがタップをキャンセルしたり、ボタンからスライドしたりしても、すぐに「閉じる」から「メニュー」に変わります。ボタンラベルの最初のテキストは「メニュー」です。

違いがあるかどうかはわかりませんが、_menuButtonのプロパティは次のとおりです。

@property (weak, nonatomic) IBOutlet UIButton *menuButton;

メニューをロードするアニメーション:

    [UIView animateWithDuration:0.50
                     animations:^{
                         [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                         _menuButton.center = CGPointMake(_menuButton.center.x + 120, _menuButton.center.y);
                         _quitButton.center = CGPointMake(_quitButton.center.x + 215, _quitButton.center.y);
                         _rulesButton.center = CGPointMake(_rulesButton.center.x + 215, _rulesButton.center.y);
                         _preferencesButton.center = CGPointMake(_preferencesButton.center.x + 215, _preferencesButton.center.y);
                         _quitButton.alpha = 1.0f;
                         _rulesButton.alpha = 1.0f;
                         _preferencesButton.alpha = 1.0f;
                         _menuButton.alpha = 1.0f;
                     } completion:^(BOOL finished) {
                         _menuButton.titleLabel.text = @"close";
                     }];

メニューをアンロードするアニメーション:

    [UIView animateWithDuration:0.50
                     animations:^{
                         [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
                         _menuButton.center = CGPointMake(_menuButton.center.x - 120, _menuButton.center.y);
                         _quitButton.center = CGPointMake(_quitButton.center.x - 215, _quitButton.center.y);
                         _rulesButton.center = CGPointMake(_rulesButton.center.x - 215, _rulesButton.center.y);
                         _preferencesButton.center = CGPointMake(_preferencesButton.center.x - 215, _preferencesButton.center.y);
                         _quitButton.alpha = 0.0f;
                         _rulesButton.alpha = 0.0f;
                         _preferencesButton.alpha = 0.0f;
                         _menuButton.alpha = 0.6f;
                     } completion:^(BOOL finished) {
                         _menuButton.titleLabel.text = @"menu";
                     }];
4

2 に答える 2

1

_menuButton.titleLabel.text = @"close";に変更

[_menuButton setTitle:@"close" forState:normal];

UIButtonクラスリファレンスを参照してください 。

于 2013-01-20T17:27:33.760 に答える
0

UIButtonは、タイトルを問い合わせて設定するためのメソッドを提供します。あなたが探しているのは:

- (void)setTitle:(NSString *)title forState:(UIControlState)state
于 2013-01-20T16:55:54.443 に答える