Skip to content
This repository was archived by the owner on Jan 26, 2021. It is now read-only.

Repository files navigation

Build StatusBuild StatusCarthage compatibleLicense

BGStatePicker

BGStatePicker is a component that allows showing different states and selecting one.

BGStatePicker demo

Usage

BGStatePicker implement is a UIControl that receive a datasource to show different states.

Example code

import BGStatePicker
//....
letopenState=BGStateable()
openState.stateText ="Open"
openState.stateBackgroundColor =.greenColor()letclosedState=BGStateable()
closedState.stateText ="Close"
closedState.stateBackgroundColor =.redColor()letstatusStates=[openState, closedState]
statePickerView.datasource =self
statePickerView.reloadData()

Datasource

extensionViewController:BGStatePickerDatasource{func numberOfState(statePickerView:BGStatePickerView)->Int{return statusStates.count
}func stateForIndex(statePickerView:BGStatePickerView, index:Int)->BGStateable{returnstatusStates[index]}}}

Get notified when the user pick a state

BGStatePicker inherits from UIControl and implements the .ValueChanged event.

//in viewDidLoad{
//....
statePickerView.addTarget(self, action: #selector(pickState(_:)), forControlEvents:[.ValueChanged])
//...
}...func pickState(sender:BGStatePickerView){iflet state = sender.selectedValue { // BGStateable
print("You pick state \(state.stateText)")}}

Installation

Carthage

github"grimabe/BGStatePicker" ~> 0.2.0

CocoaPods

pod"BGStatePicker","~> 0.2.0"

Requirements

BGStatePicker requires iOS 8 or later.

Author

Benjamin Grima

License

BGStatePicker is licensed under the MIT License.

About

BGStatePicker is an iOS UIControl which lets pick states !

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages