pod 'GCCountryPicker'
-
Add GCCountryPicker to your file's import statements.
import GCCountryPicker
-
Create an instance of GCCountryPickerViewController.
let countryPickerViewController = GCCountryPickerViewController(displayMode: .withoutCallingCodes)
-
Set the delegate, data source (optional), and navigation title.
countryPickerViewController.delegate = self countryPickerViewController.dataSource = self countryPickerViewController.navigationItem.title = "Countries"
-
Embed the country picker view controller in a navigation controller.
let navigationController = UINavigationController(rootViewController: countryPickerViewController)
-
Present the navigation controller.
self.present(navigationController, animated: true, completion: nil)
-
Implement GCCountryPickerDelegate.
func countryPickerDidCancel(_ countryPicker: GCCountryPickerViewController) func countryPicker(_ countryPicker: GCCountryPickerViewController, didSelectCountry country: GCCountry)
-
Implement GCCountryPickerDataSource if necessary.
func countryCodes(for countryPicker: GCCountryPickerViewController) -> [String]
GCCountryPicker is available under the MIT license. See the LICENSE file for more info.