CTKFlagPhoneNumber is a phone number textfield with a fancy country code picker.
Country names are displayed according to the phone language
To run the example project, clone the repo, and run pod install
from the Example directory first.
CTKFlagPhoneNumber is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "CTKFlagPhoneNumber"
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
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.
This library is high inspired of MRCountryPicker library and use libPhoneNumber-iOS library. https://github.com/xtrinch/MRCountryPicker / https://github.com/iziz/libPhoneNumber-iOS
grifas, aurelien.grifasi@chronotruck.com
Don't hesitate to contact me or make a pull request to upgrade this library.
CTKFlagPhoneNumber is available under the Apache license. See the LICENSE file for more info.