Latest 1.0.0
License MIT
Platforms ios 9.0



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


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

pod "USStatePicker"


To use the state picker first import it into your file.

import USStatePicker

Once the picker has been imported create a property to set up the delegate and load the states.

lazy var statePicker: USStatePicker = {
    let picker = USStatePicker(frame:
    picker.statePickerDelegate = self
    return picker

After the picker has been initialized then set it as the input view for a text field that will hold
the returned state.

override func viewDidLoad() {

    stateTextField.inputView = statePicker

Once the picker is set up there is one required delegate method that needs to be implemented. That
method will return the state that is selected in the picker. The method will receive a State object
that has two properties. One for the states name and one for the two character state code.

extension ViewController: USStatePickerDelegate {

    func statePickerSelectedState(state: State) {
        stateTextField.text = state.code


There are three optional delegate methods that you can use to customize the picker.

  • The first method can be used to modify the states that are available in the picker. If you don’t need all 50 states you can use this method to customize the picker for only the states that you need displayed. The format of the dictionary passed will be the two character code as the key and the state name as the value.
  • The second method can be used to change the text color in the picker. If this method is not used then the text will default to black.
  • The third method can be used to choose how the state is displayed in the picker. You can choose to display the state name or the two character state code. The default for this is the state name.
extension ViewController: USStatePickerDelegate {

    // (1)
    func statePickerAvailableStates() -> [String : String] {
        return ["GA": "Georgia", "NC": "North Carolina"]

    // (2)
    func statePickerColorForTitle() -> UIColor? {
        return UIColor.redColor()

    // (3)
    func statePickerTitleOptionForRow() -> StateRowTitleOption {
        return StateRowTitleOption.code


Latest podspec

    "name": "USStatePicker",
    "version": "1.0.0",
    "summary": "Display list of available states for an application in a UIPickerView.",
    "description": "USStatePicker is a custom UIPickerView that will allow you to easily display a list of states innyour application. The picker can be customized to show all 50 states or a subset of states basednon the needs of your application.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Donny Davis": "[email protected]"
    "source": {
        "git": "",
        "tag": "1.0.0"
    "platforms": {
        "ios": "9.0"
    "source_files": "USStatePicker/Classes/**/*"

Pin It on Pinterest

Share This