diff --git a/Pod/PinCodeTextField.swift b/Pod/PinCodeTextField.swift index 06b2438..55a5d0d 100644 --- a/Pod/PinCodeTextField.swift +++ b/Pod/PinCodeTextField.swift @@ -41,6 +41,7 @@ import UIKit @IBInspectable public var underlineColor: UIColor = UIColor.darkGray @IBInspectable public var updatedUnderlineColor: UIColor = UIColor.clear @IBInspectable public var secureText: Bool = false + @IBInspectable public var secureCharacter: String = "•" @IBInspectable public var needToUpdateUnderlines: Bool = true @IBInspectable public var characterBackgroundColor: UIColor = UIColor.clear @IBInspectable public var characterBackgroundCornerRadius: CGFloat = 0 @@ -196,7 +197,7 @@ import UIKit } private func updateLabels() { - let textHelper = TextHelper(text: text, placeholder: placeholderText, isSecure: isSecureTextEntry) + let textHelper = TextHelper(text: text, placeholder: placeholderText, isSecure: isSecureTextEntry, charSubstitute: Character(secureCharacter)) for label in labels { let index = labels.firstIndex(of: label) ?? 0 let currentCharacter = textHelper.character(atIndex: index) diff --git a/Pod/TextHelper/TextHelper.swift b/Pod/TextHelper/TextHelper.swift index f09b2a0..829a7b1 100644 --- a/Pod/TextHelper/TextHelper.swift +++ b/Pod/TextHelper/TextHelper.swift @@ -12,11 +12,13 @@ class TextHelper { let text: String? let placeholderText: String? let isSecureTextEntry: Bool + let charSubstitute: Character - init(text: String?, placeholder: String?, isSecure: Bool = false) { + init(text: String?, placeholder: String?, isSecure: Bool = false, charSubstitute: Character = "•") { self.text = text self.placeholderText = placeholder self.isSecureTextEntry = isSecure + self.charSubstitute = charSubstitute } func character(atIndex i: Int) -> Character? { @@ -25,7 +27,7 @@ class TextHelper { let character: Character? if i < inputTextCount { let string = text ?? "" - character = isSecureTextEntry ? "•" : string[string.index(string.startIndex, offsetBy: i)] + character = isSecureTextEntry ? charSubstitute : string[string.index(string.startIndex, offsetBy: i)] } else if i < placeholderTextLength { let string = placeholderText ?? ""