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

查看:14
本文介绍了禁用的 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天全站免登陆