/CTKFlagPhoneNumber

A formatted phone number UITextField with country flag picker.

Primary LanguageSwiftApache License 2.0Apache-2.0

CTKFlagPhoneNumber

CTKFlagPhoneNumber is a phone number textfield with a fancy country code picker.

CI Status Version License Platform Language

Screenshot

sample sample sample

Localization 🌍

Country names are displayed according to the phone language

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

CTKFlagPhoneNumber is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "CTKFlagPhoneNumber"

Usage

You can instance it in storyboards or .xibs.

Programmatically:

phoneNumberTextField = CTKFlagPhoneNumberTextField(frame: CGRect(x: 0, y: 0, width: view.bounds.width - 16, height: 50))

// Set the parent view controller to enable the search
phoneNumberTextField.parentViewController = self

// You can change the choosen flag
phoneNumberTextField.setFlag(with: "FR")

// You can change the phone number, that will update automatically the flag image
phoneNumberTextField.set(phoneNumber: "0600000001")

// You can also get the phone number to E164 format
print(phoneNumberTextField.getPhoneNumber()) // Output: +33600000001

Customization

FlagKit is used by default but you can customize the list with your own flag icons assets:

Bundle.FlagIcons = YOUR_FLAG_ICONS_BUNDLE

Be sure to set it before initializing a CTKFlagPhoneNumber instance.

Conception

This library is high inspired of MRCountryPicker library and use libPhoneNumber-iOS library. https://github.com/xtrinch/MRCountryPicker / https://github.com/iziz/libPhoneNumber-iOS

Author

grifas, aurelien.grifasi@chronotruck.com

Don't hesitate to contact me or make a pull request to upgrade this library.

License

CTKFlagPhoneNumber is available under the Apache license. See the LICENSE file for more info.