Fix the color the passwords

- in the password editing view
- color of some characters
This commit is contained in:
Yishi Lin 2017-03-24 01:34:45 +08:00
parent 2899f05a73
commit ca66cd8e6c
3 changed files with 9 additions and 1 deletions

View file

@ -133,7 +133,7 @@ class Utils {
for (index, element) in plainPassword.unicodeScalars.enumerated() { for (index, element) in plainPassword.unicodeScalars.enumerated() {
if NSCharacterSet.decimalDigits.contains(element) { if NSCharacterSet.decimalDigits.contains(element) {
attributedPassword.addAttribute(NSForegroundColorAttributeName, value: Globals.red, range: NSRange(location: index, length: 1)) attributedPassword.addAttribute(NSForegroundColorAttributeName, value: Globals.red, range: NSRange(location: index, length: 1))
} else if NSCharacterSet.punctuationCharacters.contains(element) { } else if !NSCharacterSet.letters.contains(element) {
attributedPassword.addAttribute(NSForegroundColorAttributeName, value: Globals.blue, range: NSRange(location: index, length: 1)) attributedPassword.addAttribute(NSForegroundColorAttributeName, value: Globals.blue, range: NSRange(location: index, length: 1))
} }
} }

View file

@ -33,6 +33,11 @@ class FillPasswordTableViewCell: ContentTableViewCell {
self.delegate?.generateAndCopyPassword() self.delegate?.generateAndCopyPassword()
} }
// re-color
@IBAction func textFieldDidChange(_ sender: UITextField) {
contentTextField.attributedText = Utils.attributedPassword(plainPassword: sender.text ?? "")
}
override func getContent() -> String? { override func getContent() -> String? {
return contentTextField.attributedText?.string return contentTextField.attributedText?.string
} }

View file

@ -27,6 +27,9 @@
<nil key="textColor"/> <nil key="textColor"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/> <fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" keyboardType="alphabet"/> <textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" keyboardType="alphabet"/>
<connections>
<action selector="textFieldDidChange:" destination="KGk-i7-Jjw" eventType="editingChanged" id="U0t-2B-JxY"/>
</connections>
</textField> </textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" reversesTitleShadowWhenHighlighted="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hTh-ek-Xam"> <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" reversesTitleShadowWhenHighlighted="YES" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hTh-ek-Xam">
<rect key="frame" x="243" y="-0.5" width="64" height="89.5"/> <rect key="frame" x="243" y="-0.5" width="64" height="89.5"/>