Sorry if the question has been already answered. I'm new to Swift, and I want to create a simple fixed-size TextField for one-time password:
TextField("******", text: self.$otp)
.padding()
.textContentType(.oneTimeCode)
.keyboardType(.numberPad)
I was hoping to find a configuration parameter similar to <input size="6"/> in HTML so that the engine would automatically compute the TextField's size for N characters.
Is there a simple solution to this without jumping through hoops like using ZStacks and spawning N text fields as I saw some enthusiasts were suggesting?
Use a fixed size TextField.
TextField("******", text: $text).fixedSize()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With