How to add Done button to Number Pad keyboard in swiftUI iOS 14

176 views Asked by At

i have a requirement to create the phone number text filed in our application, to enter the phone number i have selected number pad keyboard, in number pad there is no return button to close the keyboard, if any one knows please help me to create done button in keyboard tool bar to dismiss the keyboard.

Application minimum supported version is iOS14

Thanks in Advance.

                        // MobileNumber textfield
                        Label {
                            CustomTextfield(placeholder: Text("Mobile Number"), fontName: "Avenir", fontSize: 14, fontColor: Color.white,foregroundColor: Color.white, text: $viewModel.mobileNumber)
                                .keyboardType(.numberPad)
                                .onChange(of: viewModel.mobileNumber) { newValue in
                                    if newValue.count > 10{
                                        viewModel.mobileNumber = String(newValue.prefix(10))
                                    }
                                }
                        } icon: {
                            Image("ic_Mobile")
                                .frame(width: 14, height: 14)
                                .padding(.leading)
                        }.modifier(AuthenticationTFModifier())

this is the mobile number textField code

0

There are 0 answers