SelectableStackView is a customizable and easy to use UI element for showing and managing selectable elements in a stack written in Swift.
- Supports any number of elements
- Supports any type of elements given that it should conform to SelectionObservableView protocol
- Automatically manages elements
- Allows to manually manage elements if needed
- Supports single/multiple selection states
- Can automatically handle no selection case
- Use in code or from interface builder
- Has a delegate to observe selection
- iOS 10.0+
- Xcode 11+
- Swift 5.2+
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.
Use Xcode’s new Swift Packages option, which is located within the File menu.
import SelectableStackView
selectableStackView.addArrangedSubview(yourView) // make sure that your view conform to ObservableBySelectableStackView protocolimport SelectableStackView
selectableStackView.select(true, at: someIndex) // if view at given index doesnt exist, nothing will happenimport SelectableStackView
// 1. Conform to SelectableStackViewDelegate protocol
class SomeClass: SelectableStackViewDelegate {
let selectableStackView = SelectableStackView()
init() {
// 2. Set delegate
selectableStackView.delegate = self
}
// MARK: - SelectableStackViewDelegate
func didSelect(_ select: Bool, at index: Index, on selectableStackView: SelectableStackView) {
// handle selection
}
}selectableStackView.loggingEnabled = on // enable logging if neededimport SelectableStackView
class SomeClass: SelectableStackViewDelegate {
var shouldNotifyAboutSelfSelection: Bool { true }
}SelectableStackView is released under the MIT license. See LICENSE for details.
