A simple iOS framework that allows developers to present a list of countries.
CountryList makes it easy to present the user with a list of Countries and their respective information, like country code, phone extension and flag.
- iOS 9.0+
- Xcode 7.3+
You can use CocoaPods to install CountryList by adding this to your Podfile:
use_frameworks!
pod 'CountryList'If you get the Unable to find a specification for `CountryList`. error after running pod install.
Run the following commands on your project directory:
pod repo update
pod install
- Drag and drop
CountryList.swiftCountries.swiftCountry.swiftCountryCell.swiftin your project. - That's it!
- Import
CountryListmodule to yourViewControllerclass
import CountryList- Add
CountryListtoViewController, then set the delegate for it to self.
class ViewController: UIViewController {
var countryList = CountryList()
override func viewDidLoad() {
super.viewDidLoad()
countryList.delegate = self
}
}- Conform your
ViewControllertoCountryListDelegateprotocol and implement all the methods, e.g.
class ViewController: UIViewController, CountryListDelegate {
func selectedCountry(country: Country) {
print(country.name)
print(country.flag)
print(country.countryCode)
print(country.phoneExtension)
}
}- Present the
CountryListview onViewControllere.g.
class ViewController: UIViewController {
@IBAction func presentCountryList(_ sender: Any) {
let navController = UINavigationController(rootViewController: countryList)
self.present(navController, animated: true, completion: nil)
}
}CountryListworks with default implementation. Override it to customize its behavior
- Landscape mode is not supported
Contributions are welcomed! There are however certain guidelines you must follow when you contribute:
- Have descriptive commit messages.
- Make a pull request for every feature (Don't make a pull request that adds 3 new features. Make an individual pull request for each of those features, with a descriptive message).
- Don't update the example project, or any other irrelevant files.
Distributed under the MIT license. See LICENSE for more information.
