harsh_017
harsh_017

Reputation: 1751

Obscure a UITextField password

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?

Upvotes: 167

Views: 70491

Answers (9)

Mehul Mistri
Mehul Mistri

Reputation: 15147

Please set your UItextField property secure..

Try this..

textFieldSecure.secureTextEntry = true

textFieldSecure is your UITextField...

For newer Swift version, it is textFieldSecure.isSecureTextEntry = true

Upvotes: 335

Shekhar Gupta
Shekhar Gupta

Reputation: 6218

One can do this for Obscure a UITextField password:

enter image description here

CODE

Objective-C:

textField.secureTextEntry = YES;

Swift:

textField.isSecureTextEntry = true 

Upvotes: 82

kiran
kiran

Reputation: 4409

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.

Upvotes: 2

ipraba
ipraba

Reputation: 16543

In Interface Builder check the "Secure Text Entry" checkbox

or

In code set:

Objective-C:

yourTextField.secureTextEntry = YES;

Swift:

yourTextField.secureTextEntry = true

Upvotes: 37

Nandkishor mewara
Nandkishor mewara

Reputation: 2562

in Swift 3.0 or later

passwordTextField.isSecureTextEntry = true

Upvotes: 4

Fangming
Fangming

Reputation: 25261

Simply check Secure Text Entry check box on the storyboard

enter image description here

Upvotes: 3

somnath
somnath

Reputation: 121

For Swift 3.0:

txtpassword.isSecureTextEntry = true

Upvotes: 6

PgmFreek
PgmFreek

Reputation: 6402

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

Upvotes: 8

jtbandes
jtbandes

Reputation: 118671

Set the secureTextEntry property to YES.

Upvotes: 11

Related Questions