AceReusableViews
UITableView 和 UICollectionView 的重用视图扩展。
描述
该扩展使得从重用队列中取出视图并且用模型填充变得更加简单。
用法
注册
tableView.registerViews(TitleTableViewHeader.self, TitleTableViewFooter.self)
tableView.registerCells(TitleTableViewCell.self)
collectionView.registerView(TitleCollectionViewHeader.self, ofKind: UICollectionView.elementKindSectionHeader)
collectionView.registerCells(ColorCollectionViewCell.self)
collectionView.registerView(TitleCollectionViewFooter.self, ofKind: UICollectionView.elementKindSectionFooter)
队列取出
let cell = tableView.dequeueCell(for: indexPath) as TitleTableViewCell
let view = tableView.dequeueView() as TitleTableViewHeader?
let view = tableView.dequeueView() as TitleTableViewFooter?
let cell = collectionView.dequeueCell(for: indexPath, with: colors[indexPath.item]) as ColorCollectionViewCell
let view = collectionView.dequeueView(ofKind: kind, for: indexPath) as TitleCollectionViewHeader
let view = collectionView.dequeueView(ofKind: kind, for: indexPath) as TitleCollectionViewFooter
数据填充
return tableView.dequeueCell(for: indexPath, with: contacts[indexPath.row]) as TitleTableViewCell
return collectionView.dequeueCell(for: indexPath, with: colors[indexPath.item]) as ColorCollectionViewCell
安装
您希望将类似于以下的内容添加到您的 Podfile:
target 'MyApp' do
pod 'AceReusableViews', '~> 0.1'
end
然后在您的终端内运行 pod install。