diff --git a/pass/Views/LabelTableViewCell.swift b/pass/Views/LabelTableViewCell.swift index 1bd7d80..b34e4c3 100644 --- a/pass/Views/LabelTableViewCell.swift +++ b/pass/Views/LabelTableViewCell.swift @@ -33,6 +33,7 @@ class LabelTableViewCell: UITableViewCell { } else { contentLabel.text = cellData?.content } + contentLabel.font = UIFont(name: "Menlo", size: contentLabel.font.pointSize) } } @@ -69,7 +70,22 @@ class LabelTableViewCell: UITableViewCell { } func revealPassword(_ sender: Any?) { - contentLabel.text = cellData?.content + if let plainPassword = cellData?.content { + let attributePassword = NSMutableAttributedString.init(string: plainPassword) + // draw all digits in the password into red + // draw all punctuation characters in the password into blue + for (index, element) in plainPassword.unicodeScalars.enumerated() { + if NSCharacterSet.decimalDigits.contains(element) { + attributePassword.addAttribute(NSForegroundColorAttributeName, value: UIColor.red , range: NSRange(location: index, length: 1)) + } else if NSCharacterSet.punctuationCharacters.contains(element) { + attributePassword.addAttribute(NSForegroundColorAttributeName, value: UIColor.blue , range: NSRange(location: index, length: 1)) + } + } + // set contentLabel + contentLabel.attributedText = attributePassword + } else { + contentLabel.text = "" + } isReveal = true }