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

后端 未结 6 955
醉话见心
醉话见心 2020-12-25 09:07

I have a need to display a UITableView containing a user\'s account credentials. For this, I\'m using UILabels in UITableViewCell. Whe

6条回答
  •  旧时难觅i
    2020-12-25 09:19

    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;
    

提交回复
热议问题