代码之家  ›  专栏  ›  技术社区  ›  drewh

如何在uilabel中显示替代密码字符?

  •  8
  • drewh  · 技术社区  · 16 年前

    我需要展示 UITableView 包含用户的帐户凭据。为此,我正在使用 UILabels 在里面 UITableViewCell . 当我显示他们的密码时,显然我只想显示一个占位符密码字符,而不是他们的实际密码,类似于 UITextField 当设置为安全文本输入模式时。事实上,我想用和 输入框 使用,而不是“*”。

    我的问题是,密码字符的字符代码是什么 输入框 当它处于安全模式时?

    6 回复  |  直到 16 年前
        1
  •  8
  •   Stephen Darlington    16 年前

        2
  •  18
  •   Scott Gardner    11 年前

    // 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;
    
        3
  •  3
  •   benzado    16 年前

        4
  •  2
  •   DIJ    13 年前
        5
  •  2
  •   amadour    8 年前

        6
  •  1
  •   Max    7 年前

    passwordLabel.text = String(password.characters.map { _ in return "•" })