禁用按钮 [英] Disable a Button
本文介绍了禁用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在点击iOS后禁用一个按钮( UIButton
)。我是iOS新手,但我认为目标上的等效代码是C:
I want to disable a button (UIButton
) on iOS after it is clicked. I am new to developing for iOS but I think the equivalent code on objective - C is this:
button.enabled = NO;
但是我不能在swift上做到这一点。
But I couldn't do that on swift.
推荐答案
Swift中 NO
的布尔值为 false
。
The boolean value for NO
in Swift is false
.
button.isEnabled = false
应该这样做。
这里是 UIControl
的 isEnabled
属性的Swift文档。
Here is the Swift documentation for UIControl
's isEnabled
property.
这篇关于禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文