Skip to content

Country picker with flags and optionally phone numbers written in Swift for iOS. Swift 3 compatible.

License

Notifications You must be signed in to change notification settings

AronI/MRCountryPicker

 
 

Repository files navigation

MRCountryPicker

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
        countryPicker.setCountry("SI")
    }
    
    // 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.

Add the following line to your Podfile:

pod 'MRCountryPicker', '~> 0.0.5'

Add the following line to your Cartfile:

github "xTrinch/MRCountryPicker" ~> 0.0.5

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.

About

Country picker with flags and optionally phone numbers written in Swift for iOS. Swift 3 compatible.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 100.0%