MultiSelector
MultiSelector is a customizable multiple selector for iOS with RxSwift supported.
Documentation
MultiSelector is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'MultiSelector'
Customzied model
A customized model for a customized button must contains the title of the button.
If you want to control the isEnabled
property of the button, just add it into your customized model.
struct Model: MultiSelectorModel {
let title: String
let isEnabled: Bool
}
Customzied button
public class Button: MultiSelectorButton {
public override func configure(model: MultiSelectorModel?) {
// customized code.
}
}
Setup button
multiSelector.buttonType = Button.self
multiSelector.delegate = self
multiSelector.models = [model1, model2, ...]
multiSelector.numberOfSelectableItems = 4
multiSelector.numberOfColumns = 4
multiSelector.verticalSpaceing = 10
multiSelector.horizontalSpacing = 10
Observe selected indexes
extension ViewController: MultiSelectorDelegate {
func didSelectedIndexUpdated(indexes: [Int]) {
}
}
RxSwift supported
multiSelector.rx.indexesSelected.subscribe(onNext: { [unowned self] in
print($0.map { self.allModels[$0] })
}).disposed(by: disposeBag)
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
License
MultiSelector is available under the MIT license. See the LICENSE file for more info.