Zsolt Papp Zsolt Papp - 2 years ago 191
Swift Question

How can I change the dots to another character on password field in iOS Swift

I have a Text Field and I would like to replace the default dot character to something else when the password is hidden.
Is there any way to do this easily?

Answer Source

2 options here:

  1. Use a normal textfield without the secure input option. When a user enters a character, save it to a string variable, and replace it in the textfield with the character you wish to present instead of the bullets.

Here's the code (will show the password as $$$$):

var password: String = ""
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool
    password = password+string
    textField.text = textField.text+"$"
    return false
  1. check out the answers here: UITextField secureTextEntry bullets with a custom font?
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download