SelectionList

基于 UITableView 的简单单选或多选复选框列表。

Swift Version Build Status License CocoaPods Compatible
Platform PRs Welcome

    

用法

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]

更改外观

以下属性可以在 Interface Builder 或代码中更改

selectionList.selectionImage = UIImage(named: "v")
selectionList.deselectionImage = UIImage(named: "o")
selectionList.isSelectionMarkTrailing = false // to put checkmark on left side
selectionList.rowHeight = 42.0

您可以在代码中进行其他样式设置

selectionList.setupCell =  { (cell: UITableViewCell, index: Int) in
    cell.textLabel?.textColor = .gray
}

如果您想删除单元格分隔线

selectionList.tableView.separatorStyle = .none

要求

安装

CocoaPods

pod 'SelectionList'

旧版本

Swift 版本 SelectionList 版本
4.1 (Xcode 9.4) pod 'SelectionList', '~> 1.2.0'
4.0 pod 'SelectionList', '~> 1.0.2'

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/yonat/SelectionList", from: "1.4.5")
]

Meta

@yonatsharon

https://github.com/yonat/SelectionList