温馨提示:本文翻译自stackoverflow.com,查看原文请点击:ios - Disabled UIButton not faded or grey
cocoa-touch ios iphone uibutton

ios - 禁用的UIButton不褪色或呈灰色

发布于 2020-04-16 15:10:13

在我的iPhone应用程序中,我有一个在Interface Builder中创建的UIButton。我可以在代码中像这样成功地启用和禁用它...

sendButton.enabled = YES;

要么

sendButton.enabled = NO;

但是,按钮的外观总是一样的!它没有褪色或灰色。如果我尝试单击它,则会按预期启用或禁用它。我想念什么吗?它应该看起来不褪色还是灰色?

查看更多

提问者
Andy A
被浏览
11
1,531 2015-06-23 15:35

您可以使用以下代码:

sendButton.enabled = YES;
sendButton.alpha = 1.0;

or

sendButton.enabled = NO;
sendButton.alpha = 0.5;