BlockDataSource
瞬间创造表格和集合
简介
DataSource
是一个嵌入式DSL,用于使用UITableViews和UICollectionViews构建UI。您定义列表的结构,DataSource将自动遵循UITableViewControllerDataSource
、UITableViewControllerDelegate
、UICollectionViewControllerDataSource
和U ICollectionViewControllerDelegate
。
例如,以下是创建简单的UITableViewController的方式
let vc = BlockTableViewController(
style: .grouped,
dataSource: DataSource(
sections: [
Section(
items: [
Item { (cell: BedazzledTableViewCell) in
cell.titleLabel.text = "Custom cells"
},
Item { (cell: SubtitleTableViewCell) in
cell.textLabel?.text = "Load any cell with ease"
cell.detailTextLabel?.text = "BlockDataSource automatically registers and loads the correct cell by using the class specified in the configure block."
cell.detailTextLabel?.numberOfLines = 0
}
]
)
],
middleware: [
Middleware.noCellSelectionStyle,
Middleware.separatorInset(UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0))
]
)
)
安装
BlockDataSource可通过CocoaPods获取。要安装它,只需在Podfile中添加以下行即可
pod "BlockDataSource"
作者
Adam Cumiskey,[email protected]
许可
BlockDataSource遵循MIT许可证。更多信息请参阅LICENSE文件。