Skip to content

A simple, customizable Country picker for picking country or dialing code.

License

Notifications You must be signed in to change notification settings

nikki003/CountryPicker

 
 

Repository files navigation

Version License
my_tweet 1

CountryPicker

A simple, customizable Country picker for picking country or dialing code.
This library is for country picker used in many app for selecting country code of user. User can select country by searching and then selecting country in list.

If you like CountryPicker, give it a ★ at the top right of this page.

Features

  • Navigate through search and index title of section e.g (in Contact app in iOS)
  • cocoa Pods integrated
  • Best practices followed

Requirements

  • iOS 10.0+
  • Xcode 9+

Example

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

Installation

CountryPicker is available through Cocoapods.

Add the following line to your Podfile:

pod 'SKCountryPicker'

current version compatible with Swift 4.1 as well Swift 3.3

Getting Started

Example:

import UIKit
import SKCountryPicker
class ViewController: UIViewController  {
  //MARK:- IBOutlet
  @IBOutlet weak var countryCodeButton: UIButton!
  @IBOutlet weak var countryImageView: UIImageView!
  let contryPickerController = CountryPickerController()
  
  //MARK:- Func
  override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
   
    let country = CountryManager.shared.currentCountry
    countryCodeButton.setTitle(country?.dialingCode, for: .normal)
    countryImageView.image = country?.flag
    countryCodeButton.clipsToBounds = true
    
  }
  
  
  @IBAction func countryCodeButtonClicked(_ sender: UIButton) {
    
    let countryController = CountryPickerWithSectionViewController.presentController(on: self) { (country: Country) in
      self.countryImageView.image = country.flag
      self.countryCodeButton.setTitle(country.dialingCode, for: .normal)

    }
    // can customize the countryPicker here e.g font and color
    countryController.detailColor = UIColor.red
   }
}

Contributing

Any contribution making project better is welcome.

ScreenShots

In Example Project

Demo

Above is a Gif demo.

After running the project by default current country get selected as below.

defaultopenimage

On clicking on this button country picker open with the option of choose or filter the require country. step2image

After selecting selected country with image will appear on your button. simulator screen shot - iphone 5s - 2017-10-29 at 17 32 52 simulator screen shot - iphone 5s - 2017-10-29 at 17 32 56

Authors

*Suryakant Sharma

See also the list of contributors who participated in this project. Thanks from bottom of my heart to inspiration behind Hardeep Singh

License

This project is licensed under the MIT License - see the LICENSE file for details

About

A simple, customizable Country picker for picking country or dialing code.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Swift 74.5%
  • Ruby 24.3%
  • Objective-C 1.2%