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

sendButton.enabled = YES;

sendButton.enabled = NO;

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

推荐答案

您可以使用以下代码:

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

or

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

Ios相关问答推荐

Un托管和withUnsafePointer API之间的区别?

使用音频单元播放音频流,出现爆裂声

使用CGAffineTransform旋转视图只起作用一次吗?

SWIFT设备方向更新不正确

如何在PINCH上添加UITextfield以zoom 图像

如何将Safari调试器附加到Turbo-iOS原生应用中的模拟器

无法添加以供审阅-Xcode 15.0.1

不使用故事板创建 iMessage 应用程序

如何更改 SwiftUI 弹出视图的大小?

Flutter firebase_auth 中的无效应用程序凭据/令牌不匹配

SwiftUI 中的描边图像边框

如何包含 Xcode 子项目标头?

类型任何视图不能符合具有泛型的协议上的视图

如何快速设置条形按钮的图像?

Got Unrecognized selector -replacementObjectForKeyedArchiver: 在 Swift 中实现 NSCoding 时崩溃

UIButton 事件.有什么不同?

~= Swift 中的运算符

如何以编程方式切换 UISegmentedControl?

iOS UITextView 或 UILabel 带有可点击的动作链接

测试目标 X 遇到错误(提前意外退出,操作从未完成 bootstrap - 不会try 重新启动