Skip to content

Commit f15e199

Browse files
committed
Update example
1 parent f00a7d9 commit f15e199

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Example/Example/ViewController.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class ViewController: UIViewController, FormattedTextFieldDelegate {
1414

1515
override func viewDidLoad() {
1616
super.viewDidLoad()
17+
textField.textFormatter = MaskTextFormatter(mask: "+× ××× ××× ××××××××")
1718
// Do any additional setup after loading the view, typically from a nib.
1819
}
1920

@@ -25,8 +26,11 @@ class ViewController: UIViewController, FormattedTextFieldDelegate {
2526
// MARK: - Actions
2627

2728
@IBAction private func textFieldTextChanged(_ textField: FormattedTextField) {
28-
let textMask = mask(forPhoneNumber: textField.unformattedText ?? "")
29-
textField.textMask = textMask ?? "+× ××× ××× ××××××××"
29+
let textMask = mask(forPhoneNumber: textField.unformattedText ?? "") ?? "+× ××× ××× ××××××××"
30+
let formatter = textField.textFormatter! as! MaskTextFormatter
31+
if formatter.mask != textMask {
32+
textField.textFormatter = MaskTextFormatter(mask: textMask)
33+
}
3034
}
3135

3236
// MARK: - FormattedTextFieldDelegate

0 commit comments

Comments
 (0)