CollectionView adpter
DispatchQueue.global().async {
var testData = UICollectionViewAdapterData()
for i in 0...10 {
let sectionInfo = UICollectionViewAdapterData.SectionInfo()
testData.sectionList.append(sectionInfo)
sectionInfo.header = UICollectionViewAdapterData.CellInfo(contentObj: "@@ header @@ \(i)",
sizeClosure: { return CGSize(width: UIScreen.main.bounds.size.width, height: 150) },
cellType: TestCollectionReusableView.self) { (name, object) in
guard let object = object else { return }
print("header btn ---- \(name) : \(object)")
}
sectionInfo.footer = UICollectionViewAdapterData.CellInfo(contentObj: " --- footer --- \(i)", cellType: TestFooterCollectionReusableView.self)
for j in 0...5 {
let cellInfo = UICollectionViewAdapterData.CellInfo(contentObj: "cell \(j)",
sizeClosure: { return CGSize(width: UIScreen.main.bounds.size.width, height: 50) },
cellType: TestCollectionViewCell.self) { (name, object) in
guard let object = object else { return }
print("cell btn ---- \(name) : \(object)")
}
sectionInfo.cells.append( cellInfo )
}
}
DispatchQueue.main.async {
self.collectoinView.adapterData = testData
self.collectoinView.reloadData()
}
}
link |
Stars: 2 |
Last commit: 4 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics