Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I display a substitute password character in a UILabel?

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?

like image 889
drewh Avatar asked Sep 17 '08 14:09

drewh


3 Answers

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;
like image 174
Scott Gardner Avatar answered Nov 09 '22 20:11

Scott Gardner


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

like image 24
Stephen Darlington Avatar answered Nov 09 '22 18:11

Stephen Darlington


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.

like image 3
benzado Avatar answered Nov 09 '22 18:11

benzado