You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let formatter =DefaultTextFormatter(textPattern: "## ###-##")
109
+
formatter.unformat("99 888-77") // 9988877
113
110
```
114
111
### Formatting during typing
115
112
116
-
It is necessary to create TextInputController instance with formatter for formatting during typing. You need to implement `TextInput` protocol in your own `UITextField`/`UITextView`/something else or use ready solutions (`TextInputField`/`TextInputView`) by subclassing. It is necessary to set controllers's `textInput` property.
117
-
118
-
```swift
119
-
let textInputController =TextInputController()
120
-
121
-
let textInput =TextInputField() // or TextInputView or any TextInput
The controller listens `textInput(_:shouldChangeCharactersIn:replacementString:)` delegate method. But you can also add more than one delegate if needed. Methods of the delegates, that should return `Bool` value gather using `&&` operator. Therefore, if one of the delegates returns `false`, that means that `textInput` will receive `false`. If you want to send `true` to `textInput`, all delegates must return `true`.
128
-
129
-
You can set `allowedSymbolsRegex` to the formatter to filter input symbols with the RegEx. All symbols, that satisfy the RegEx will be available for typing in the `textInput`.
130
-
This property only applies to inputed symbols from the keyboard, but not to the prefix.
113
+
Code from example app
131
114
132
115
```swift
133
-
inputFieldFormatter.allowedSymbolsRegex="[0-9]"// allowed only numbers
134
-
```
116
+
let formatter =DefaultTextInputFormatter(textPattern: "### (###) ###-##-##")
135
117
136
-
### Attributes for range
137
-
138
-
To set attributes for string at range use `addAttributes(_:range:)` method for `textInput`.
0 commit comments