禁用UIButton不褪色或灰色 [英] Disabled UIButton not faded or grey

查看:131
本文介绍了禁用UIButton不褪色或灰色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In my iPhone app, I have a UIButton which I have created in Interface Builder. I can successfully enable and disable it like this in my code ...

sendButton.enabled = YES;

sendButton.enabled = NO;

然而,按钮的视觉外观总是一样的!它没有褪色或灰色。如果我尝试单击它,则会按预期启用或禁用它。我错过了什么吗?它不应该看起来褪色或灰色吗?

However, the visual look of the button is always the same! It is not faded or grey. If I attempt to click it though, it is enabled or disabled as expected. Am I missing something? Shouldn't it look faded or grey?

谢谢

推荐答案

您可以使用以下代码:

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

or

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

这篇关于禁用UIButton不褪色或灰色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆