Specify colors for digits and letters in password
This commit is contained in:
parent
f3551a1542
commit
6ea47766bc
2 changed files with 4 additions and 2 deletions
|
|
@ -52,6 +52,8 @@ public class Globals {
|
||||||
// UI related
|
// UI related
|
||||||
public static let red = UIColor(red:1.00, green:0.23, blue:0.19, alpha:1.0)
|
public static let red = UIColor(red:1.00, green:0.23, blue:0.19, alpha:1.0)
|
||||||
public static let blue = UIColor(red:0.00, green:0.48, blue:1.00, alpha:1.0)
|
public static let blue = UIColor(red:0.00, green:0.48, blue:1.00, alpha:1.0)
|
||||||
|
public static let letterColor = UIColor(red:200/255.0, green:40/255.0, blue:41/255.0, alpha:1.0)
|
||||||
|
public static let digitColor = UIColor(red:66/255.0, green:113/255.0, blue:174/255.0, alpha:1.0)
|
||||||
public static let tableCellButtonSize = CGFloat(20.0)
|
public static let tableCellButtonSize = CGFloat(20.0)
|
||||||
|
|
||||||
private init() { }
|
private init() { }
|
||||||
|
|
|
||||||
|
|
@ -107,9 +107,9 @@ public class Utils {
|
||||||
for (index, element) in plainPassword.unicodeScalars.enumerated() {
|
for (index, element) in plainPassword.unicodeScalars.enumerated() {
|
||||||
var charColor = UIColor.darkText
|
var charColor = UIColor.darkText
|
||||||
if NSCharacterSet.decimalDigits.contains(element) {
|
if NSCharacterSet.decimalDigits.contains(element) {
|
||||||
charColor = Globals.red
|
charColor = Globals.digitColor
|
||||||
} else if !NSCharacterSet.letters.contains(element) {
|
} else if !NSCharacterSet.letters.contains(element) {
|
||||||
charColor = Globals.blue
|
charColor = Globals.letterColor
|
||||||
}
|
}
|
||||||
attributedPassword.addAttribute(NSAttributedStringKey.foregroundColor, value: charColor, range: NSRange(location: index, length: 1))
|
attributedPassword.addAttribute(NSAttributedStringKey.foregroundColor, value: charColor, range: NSRange(location: index, length: 1))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue