Skip to content

ChadChang/CCRegionSelector

Repository files navigation

CCRegionSelector

Swift Version Version CI-iOS Platform License

Default Custom Picker
DEMO Custom picker

Example

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

Usage

Add the CCRegionSelectorView to your View, then follow RegionSelectorViewDelegate protocol

  • showPickInView() return a view where UIPickerView placed
  func showPickInView()->UIView {
    return self.view
  }
  • phoneCodeDidChange() will receive a phone code where user select a region.
  func phoneCodeDidChange(phoneCode: String) {
    print(phoneCode)
  }
  • customPickerView(_ info: RegionInfo) retrun a picker view
    func customPickerView(_ info: RegionInfo) -> UIView? {
        // return nil if use default picker view
        nil
        // use custom picker view
        // RandomColorRegionPickerView(regionInfo: info)
    }

Optional

  • setDefaultRegion() to set an initial region.
  selectView.setDefaultRegion("TW")
  • By passing a string array to setPinRegions() to mark frequently used.
  selectView.setPinRegions(["TW", "CA"])
  • By passing a string array to setRestrictRegions() to show only those regions desired.
  selectView.setRestrictRegions(["TW","US","CA"])

Installation

CCRegionSelector is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'CCRegionSelector'

Or once you have your Swift package set up, adding it as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [ .package(url: "https://github.com/ChadChang/CCRegionSelector.git", .upToNextMajor(from: "1.0")) ]

Author

ChadChang, chadchang.tw at gmail.com

License

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

Attributions