Simple single-selection or multiple-selection checklist, based on UITableView.
let selectionList = SelectionList()
selectionList.items = ["One", "Two", "Three", "Four", "Five"]
selectionList.addTarget(self, action: #selector(selectionChanged), for: .valueChanged)
selectionList.selectedIndex = 3
selectionList.allowsMultipleSelection = true
selectionList.selectedIndexes = [0, 1, 4]
The following properties can be changed either in Interface Builder or in code:
selectionList.selectionImage = UIImage(named: "v")
selectionList.deselectionImage = UIImage(named: "o")
selectionList.isSelectionMarkTrailing = false // to put checkmark on left side
selectionList.rowHeight = 42.0
You can do additional styling in code:
selectionList.setupCell = { (cell: UITableViewCell, index: Int) in
cell.textLabel?.textColor = .gray
}
- iOS 9.0+
- Xcode 9+
pod 'SelectionList'
Copy Sources/SelectionList.swift
to your Xcode project.