gpt4 book ai didi

ios - 如何禁用 UIButton 3 秒?

转载 作者:行者123 更新时间:2023-11-28 20:02:57 25 4
gpt4 key购买 nike

重要编辑:我是 Obj-C 和 iOS 开发的初学者。

当我的 UIButton 被按下时,一个标签淡入。这个标签需要 3 秒才能淡入。我将如何在这 3 秒内禁用 UIButton?

这就是我正在尝试的:

[UIView animateWithDuration:3.0f animations:^{
self.button.enabled = NO;
self.quoteLabel.alpha = 1.0f;
self.quoteLabel.text = self.quotes.randomQuote;
self.labelForNumberOfTimesRead.text = [NSString stringWithFormat:@"+ %d",numberOfTimesRead ];

}];
self.button.enabled = YES;

但它只会“瞬间”禁用。

最佳答案

你可以像这样简单地做,

self.button.enabled = NO;
self.quoteLabel.text = self.quotes.randomQuote;
self.labelForNumberOfTimesRead.text = [NSString stringWithFormat:@"+ %d",numberOfTimesRead ];
[UIView animateWithDuration:3 animations:^{
self.quoteLabel.alpha = 1.0f;
} completion:^(BOOL finished) {
self.button.enabled = YES;
}
];

不清楚您在使用 labelForNumberOfTimesRead 做什么。你想让那个也淡入(或淡出)吗?

关于ios - 如何禁用 UIButton 3 秒?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23190738/

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