OYTableView 0.1.2

OYTableView 0.1.2

Osman YILDIRIM 维护。



  • 作者:
  • osmanyildirim

OYTableView

CI Status Version License Platform

示例

要运行示例项目,请克隆仓库,然后首先从示例目录运行 pod install

需求

安装

CocoaPods

OYTableView可通过CocoaPods获取。要安装它,请添加以下行到您的 Podfile。

pod 'OYTableView'

在您希望使用 OYTableView 的任何文件中,不要忘记使用 import OYTableView 导入框架。

手动

OYTableView.swift, OYHeaderView.swift, OYTableViewProtocol.swift 文件下载并拖放到您的项目中。

用法

extension ViewController: OYTableViewDataSource, OYTableViewDelegate {
   func numberOfSections(in oyTableView: UITableView) -> Int {
       return 1
   }

   func oyTableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
       return headers.count
   }

   func oyTableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
       return 40
   }

   func oyTableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
       return UITableView.automaticDimension
   }

   func oyTableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
       let headerView = TableHeader(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 40))
       headerView.configure(headers[section])
       return headerView
   }

   func oyTableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
       let cell = tableView.dequeueReusableCell(withIdentifier: "TableCell", for: indexPath) as? TableCell
       cell?.configure(UIImage(named: String(indexPath.row))!)
       return cell ?? UITableViewCell()
   }

   func oyTableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

   }

   func oyTableView(_ tableView: UITableView, section: Int, didExpand header: OYHeaderView) {

   }

   func oyTableView(_ tableView: UITableView, section: Int?, didCollapse header: OYHeaderView) {

   }
}

许可证

OYTableView遵循MIT许可证。有关更多信息,请参阅 `LICENSE` 文件。