Latest 0.0.7
Homepage https://github.com/xtrinch/MRCountryPicker
License MIT
Platforms ios 8.0
Authors

CI Status
Version
License
Platform
Carthage compatible

Versions below 0.0.4 are Swift 2.2 compatible, Version 0.0.5+ is Swift 3 compatible.

Example

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

screen shot 2016-06-11 at 13 00 05

Usage

Make your UIPickerView a class of MRCountryPicker, set its countryPickerDelegate and implement its countryPhoneCodePicker method.

See the following example:

class ViewController: UIViewController, MRCountryPickerDelegate {

    @IBOutlet weak var countryPicker: MRCountryPicker!
    @IBOutlet weak var countryName: UILabel!
    @IBOutlet weak var countryCode: UILabel!
    @IBOutlet weak var countryFlag: UIImageView!
    @IBOutlet weak var phoneCode: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()
        countryPicker.countryPickerDelegate = self
        countryPicker.showPhoneNumbers = true

        // set country by its code
        countryPicker.setCountry("SI")

        // optionally set custom locale; defaults to system's locale
        countryPicker.setLocale("sl_SI")

        // set country by its name
        countryPicker.setCountryByName("Canada")
    }

    // a picker item was selected
    func countryPhoneCodePicker(picker: MRCountryPicker, didSelectCountryWithName name: String, countryCode: String, phoneCode: String, flag: UIImage) {
        self.countryName.text = name
        self.countryCode.text = countryCode
        self.phoneCode.text = phoneCode
        self.countryFlag.image = flag
    }

}

Installation

MRCountryPicker is available through Cocoapods and Carthage.

CocoaPods:

Add the following line to your Podfile:

pod 'MRCountryPicker', '~> 0.0.7'

Carthage:

Add the following line to your Cartfile:

github "xTrinch/MRCountryPicker" ~> 0.0.7

Author

xtrinch, [email protected]

Made with a little help from my friends over at:
https://github.com/marmelroy/PhoneNumberKit
https://github.com/Keyflow/CountryPicker-iOS-Swift
https://github.com/nicklockwood/CountryPicker

License

MRCountryPicker is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "MRCountryPicker",
    "version": "0.0.7",
    "summary": "Country picker with flags and optional phone numbers for iOS written in Swift.",
    "description": "Country picker with flags and optional phone numbers for iOS written in Swift. Has the option to set initial country, delegate functions return country code, country name, country phone prefix and country flag. Swift 3 support.",
    "homepage": "https://github.com/xtrinch/MRCountryPicker",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Mojca Rojko": "[email protected]"
    },
    "source": {
        "git": "https://github.com/xtrinch/MRCountryPicker.git",
        "tag": "0.0.7"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "MRCountryPicker/Classes/**/*",
    "resource_bundles": {
        "SwiftCountryPicker": [
            "MRCountryPicker/Assets/SwiftCountryPicker.bundle/*"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This