Question

I have a need to display a UITableView containing a user's account credentials. For this, I'm using UILabels in UITableViewCell. When I display their password, I'd obviously like to just display a placeholder password character instead of their actual password, similar to a UITextField when it's set to secure text entry mode. In fact, I'd like to use the same character as UITextField uses, instead of '*'.

My question is, what is the character code for the password character the UITextField when it's in secure mode?

Was it helpful?

Solution

Why not just use a UITextField, make the field non-editable and change the border style to make it look like a UILabel?

OTHER TIPS

Here's a way to do this, e.g., to display the password "dotted out" in a Prototype Cell's detailTextLabel:

// self.password is your password string
NSMutableString *dottedPassword = [NSMutableString new];

for (int i = 0; i < [self.password length]; i++)
{
    [dottedPassword appendString:@"●"]; // BLACK CIRCLE Unicode: U+25CF, UTF-8: E2 97 8F
}

cell.detailTextLabel.text = dottedPassword;

The password character is probably a bullet. On a Mac, option-8 will insert one wherever you are typing. The Character Palette says it is Unicode 2022 and UTF8 E2 80 A2.

Although a very old question, I came across the same problem. benzado has the right idee, although I think the Unicode should be 25cf. To me it looks like that's exactly the dot apple uses in a secured UITextField.

In iOS 10, the BLACK CIRCLE Unicode character is not consistent with the secure text field anymore. The character to use is ⦁ "Z NOTATION SPOT" (U+2981).

In Swift 3 you can use:

passwordLabel.text = String(password.characters.map { _ in return "•" })
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top