测试测试通过 | ✓ |
Lang语言 | SwiftSwift |
许可证 | MIT |
发布最新版本 | 2017 年 10 月 |
SPM支持 SPM | ✗ |
由 Alfredo Delli Bovi 和 Nelson 维护。
赋予 UITableView
无痛的多类型单元支持及内置自动状态过渡动画
TableViewKit 是为了简化开发而设计的
UITableView
的代理创建一个包含 UITableViewCell
和 CellDrawer
的 Item
。一个 Item 可能有显示所需数据的模型,并可控制任何交互。
class YourDrawer: CellDrawer {
// The type could be a custom UITableViewCell class, with or without a Nib
static var type = CellType.class(YourCustomCell.self)
static func draw(_ cell: YourCustomCell, with item: YourItem) {
// Draw by setting properties of your cell from the item
}
}
class YourItem: Item {
var drawer = AnyCellDrawer(YourDrawer.self)
// Your properties and methods
public init() { }
}
使用您的项目创建自定义 Section
。
class YourSection: Section {
var items: ObservableArray<Item>
var header: HeaderFooterView = .title("Your section")
public init() {
items = [YourItem(), AnotherItem(), AndAnotherItem()]
}
}
一切准备就绪,实例化一个 TableViewManager
,并在您的带有 UITableView
的 UIViewController
中传递自定义分区数组。
class ViewController: UIViewController {
var tableViewManager: TableViewManager!
@IBOutlet weak var tableView: UITableView! {
didSet {
tableViewManager = TableViewManager(tableView: tableView, sections: [CustomSection])
}
}
}
/TableViewKit
文件夹拖到您的项目中。