0

I would like to know how can I implement a mask in Swift to format the input in a UITextField in real time as a Telephone number. I was looking for but I've only found complex code, I think it would be more simple. Correct me if I'm wrong. The desired mask I describe below.

000-00-00-00
Edu
  • 460
  • 12
  • 34

3 Answers3

2

Maybe you want to checkout this pod i've created some while ago:

TLCustomMask

It is really simple to use.

result:

enter image description here

Edudjr
  • 1,676
  • 18
  • 28
0

It is not that simple. Anyway this question is already answered here.

Or you can look for a library in the github such as: PhoneNumberKit

Community
  • 1
  • 1
ridvankucuk
  • 2,407
  • 1
  • 23
  • 41
0

The InputMask_ library supports the formatting you'd like to achieve.

Your subject requires some extensive text/cursor watching with lots of edge cases; I'd highly recommend to use a ready solution.