Member-only story
Create Phone Number TextField With Country Codes and Flags in SwiftUI
A beautiful way to ask your users for their contact info

We will present two methods of creating a phone number view that displays a country code and its flag. The first method contains a list of all the country codes for the user to pick. The second method will show the relevant flag whenever the user enters a valid country code.
First Method
Country code functions
Create a view struct that contains a dictionary of all the country codes we are going to have:
To have the full country name in your application, add the function below that takes in a country code and returns the full name: