165

I am doing a login page. I have UITextField for password.

Obviously, I do not want the password to be seen; instead, I want circles to show when typing. How do you set the field for this to happen?

4

9 回答 9

323

Please set your UItextField property secure..

Try this..

textFieldSecure.secureTextEntry = true

textFieldSecure is your UITextField...

于 2011-07-05T06:46:55.703 回答
82

One can do this for Obscure a UITextField password:

enter image description here

CODE

Objective-C:

textField.secureTextEntry = YES;

Swift:

textField.isSecureTextEntry = true 
于 2013-07-23T08:37:21.527 回答
37

In Interface Builder check the "Secure Text Entry" checkbox

or

In code set:

Objective-C:

yourTextField.secureTextEntry = YES;

Swift:

yourTextField.secureTextEntry = true
于 2011-07-05T06:50:47.890 回答
11

Set the secureTextEntry property to YES.

于 2011-07-05T06:48:07.890 回答
8

Open the Xib file and open the inspector of the password text field and tick the secure property.

于 2011-07-05T07:14:28.000 回答
6

For Swift 3.0:

txtpassword.isSecureTextEntry = true
于 2016-12-15T10:39:52.107 回答
4

in Swift 3.0 or later

passwordTextField.isSecureTextEntry = true
于 2017-04-06T06:24:59.660 回答
3

Simply check Secure Text Entry check box on the storyboard

enter image description here

于 2017-07-13T17:26:32.563 回答
2
txt_Password = new UITextField {
  Frame = new RectangleF (20,40,180,31),
  BorderStyle = UITextBorderStyle.Bezel,
  TextColor = UIColor.Black,
  SecureTextEntry = true,
  Font = UIFont.SystemFontOfSize (17f),
  Placeholder = "Enter Password",
  BackgroundColor = UIColor.White,
  AutocorrectionType = UITextAutocorrectionType.No,
  KeyboardType = UIKeyboardType.Default,
  ReturnKeyType = UIReturnKeyType.Done,
  ClearButtonMode = UITextFieldViewMode.WhileEditing,
};

secureTextEntry set true.

于 2014-07-08T08:36:05.823 回答