简体   繁体   English

如何在Xcode中禁用按钮?

[英]How can I disable a button in Xcode?

I am new to iPhone development. 我是iPhone开发的新手。 I am building an app by using Xcode but now would like to disable a button. 我正在使用Xcode构建应用程序,但现在想要禁用按钮。 How is this possible? 这怎么可能?

myButton.enabled = NO;

Via code: 通过代码:

myButton.enabled = NO;

If you're using interface builder there's an "enabled" option. 如果您正在使用界面构建器,则会显示“已启用”选项。

如果您正在寻找Swift 3.0解决方案:

button.isEnabled = false

button.enabled = NO; button.enabled = NO;

you can set the button property to no and if interface builder you can uncheck the property 您可以将button属性设置为no,如果界面构建器可以取消选中该属性

 button.enabled = true; 

this will ENABLE the button 这将启用按钮

button.enabled = false;

this will DISABLE the button. 这将禁用按钮。 If you want to hide the button you can do this 如果要隐藏按钮,可以执行此操作

button.alpha = 0.0;

and if you want to show the button once more you can do this. 如果你想再次显示按钮,你可以这样做。

button.alpha = 1.0

Hope this helps! 希望这可以帮助! :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM