gpt4 book ai didi

ios - UIButton 标签在选择时不尊重先前动画的完成处理程序设置的文本

转载 作者:行者123 更新时间:2023-11-29 04:10:55 24 4
gpt4 key购买 nike

在 _menuButton 的 touchUpInside 调用中,我执行动画来显示带有完成 block 的菜单,以将菜单的标签从“打开”更改为“关闭”。该动画效果很好,但是当您按下 _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";
}];

最佳答案

_menuButton.titleLabel.text = @"close"; 更改为

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

UIButton Class Reference.

关于ios - UIButton 标签在选择时不尊重先前动画的完成处理程序设置的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14426669/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com