Skip to content

Conversation

bcylin
Copy link
Collaborator

@bcylin bcylin commented Jan 21, 2018

Add an easy to use OptionPickerControl that displays a UIPickerView with given options:

An example type that conforms to OptionDescriptive:

extension String: OptionDescriptive {

  var title: String {
    return self
  }

  static var titleForOptionalValue: String {
    return "(optional)"
  }

}

Initialize OptionPickerControl with CGRect.zero and add it to the view hierarchy:

let optionPicker = OptionPickerControl<String>()
optionPicker.options = [Option<String>.optional(), Option("Option 1"), Option("Option 2")]
optionPicker.addTarget(self, action: #selector(didChangeOption(_:)), for: .valueChanged)
view.addSubview(optionPicker)

To show the UIPickerView:

optionPicker.becomeFirstResponder()

The specified selector didChangeOption(_:) will be called when the selected row in UIPickerView changes.

@bcylin bcylin force-pushed the feature/option-picker-control branch from bfe594e to b68c036 Compare January 23, 2018 09:22
@bcylin bcylin force-pushed the feature/option-picker-control branch from c92e6c3 to 877e79f Compare April 10, 2018 14:59
@bcylin bcylin added this to the v2.0.0 milestone Apr 12, 2018
@bcylin bcylin force-pushed the feature/option-picker-control branch from 877e79f to f4f2900 Compare June 5, 2018 11:17
@bcylin bcylin merged commit 8765c5d into develop Sep 30, 2018
@bcylin bcylin deleted the feature/option-picker-control branch September 30, 2018 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants