如何在xcode中创建密码字段

时间:2012-09-16 21:49:52

标签: xcode4

我正在尝试创建一个iPhone应用程序,我将让用户登录他们的帐户。 为此,我想要用户的userID和密码。我的问题是我如何设置密码 我输入的任何字段都将显示为“*”。

1 个答案:

答案 0 :(得分:73)

听起来您正在“setSecureTextEntry”对象上寻找“UITextField”。

也称为the "secureTextEntry" property in the "UITextInputTraits" protocol

您可以通过在要为密码设置的“.secureTextEntry = YES”对象上调用“UITextField”来以编程方式调用此方法。

您也可以在Interface Builder中设置它(在文本字段Attributes inspector中查找“Secure”复选框)。它看起来像这样:

SecureAttributeForTextField

在较新版本的Xcode中:

SecureAttributeForTextField In Newer Xcode