禁用的 UIButton 不褪色或变灰

Disabled UIButton not faded or grey(禁用的 UIButton 不褪色或变灰)
本文介绍了禁用的 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 不褪色或变灰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)