I have a text field where the user enters data. It's a phone number field. If the user enters 1234567890
, I want it displayed as (123)-(456)-7890
as the user types. How is this possible?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Xcode: Is there a way to change line spacing (UI L
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
You can use AKNumericFormatterlibrary for it. It has formatter and convenient UITextField category, it's available as a cocoapod.
So this method will format for (xxx) xxx - xxxx ....
it is a modification of the current top answer and handles backspaces
hope it helps
Here's a simple category which will mimic the format of the input
example use
REFormattedNumberField is probably the best. Just supply a format you wish.
Otherwise, groups of three. To adjust the size of the groups, change the value assigned to substrsize