DataSorcery
从无到有施展表格和集合
介绍
DataSource
是一个内嵌的领域特定语言(DSL),用于用UITableViews和UICollectionViews构建用户界面。您定义列表的结构,DataSource将自动符合UITableViewControllerDataSource
、UITableViewControllerDelegate
、UICollectionViewControllerDataSource
和UICollectionViewControllerDelegate
。
例如,以下是创建一个简单的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 = "Sorcery 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))
]
)
)
安装
DataSorcery可通过CocoaPods获取。要安装它,只需将以下行添加到您的Podfile中
pod "DataSorcery"
作者
Adam Cumiskey, [email protected]
许可
Sorcery遵循MIT许可证。有关更多信息,请参阅LICENSE文件。