SimpleCell 0.7.0

SimpleCell 0.7.0

mjun维护。



  • 作者:
  • devmjun

Swift Build Status pod compatible Carthage compatible codecov

SimpleCell

一个用于可重用CollectionView和TableView单元格的Swift扩展。

概述

之前

tableView.register(UItableViewCell, forCellWithReuseIdentifier: "Cell")
tableView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! UserCell

手动编写标识符时可能会出错。

之后

tableView.register(cell: TableViewCell.self)
let cell = tableView.dequeue(TableViewCell.self)

标识符会自动生成,其名称与类名相同。

使用方法

TableView

// 1. register
tableView.register(cell: TableViewCell.self)

// 2. dequeue 
tableView.dequeue(TableViewCell.self)
// or
tableView.dequeue(TableViewCell.self, indexPath: indexPath)

CollectionView

// 1. register
collectionView.register(cell: CollectionViewCell.self)
// or when using supplementary views. 
collectionView.register(cell: CollectionReusableView.self, forSupplementaryViewOfKind: .header)
collectionView.register(cell: CollectionReusableView.self, forSupplementaryViewOfKind: .footer)

// 2. dequeue 
collectionView.dequeue(CollectionView.self)
// or when using supplementary views. 
collectionView.dequeue(CollectionReusableHeaderView.self, .header, indexPath: indexPath)
collectionView.dequeue(CollectionReusableFooterView.self, .footer, indexPath: indexPath)

需求

SimpleCell 需要 iOS 8 及以上版本,并使用 Swift 5.0 编写

安装

CocoaPods

CaseContainer 可以通过CocoaPods获取。要安装,只需在 podfile 中添加以下行

pod 'SimpleCell', '~> 0.6.0'

并运行 pod install

Carthage

CaseContainer 可以通过Carthage获取。只需使用以下命令通过Homebrew安装 carthage

$ brew update
$ brew install carthage

将 CaseContainer 添加到您的 Cartfile

github "devmjun/SimpleCell" ~> 0.6.0

然后运行 carthage update

贡献

欢迎提交错误报告、拉取请求以及任何讨论。

许可证

SimpleCell 可在适用于 MIT 许可证