SwiftUI Formatting TextField for credit card input "xxxx-xxxx-xxxx-xxxx"
I want to write a custom TextField on SwiftUI to have an input with credit card format like this "xxxx-xxxx-xxxx-xxxx", I was looking at this answers https://stackoverflow.com/a/48252437, but I'm struggling with UIViewRepresentable, when I want to past the numbers into the original text, it doesn't seems to update it with the format. The textField will show you 12345, but I need 1234 5 struct ContentView: View { @State var cardNumber: String = "12345" // <-- It won't be formatted until I type another one number var body: some View { VStack { CreditCardTextField(number: $cardNumber) .frame(heig
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.