SListView

Language License CocoaPods Carthage

Swift 列表视图集合。

🔧 安装

CocoaPods

pod "SLSListView" 这行添加到你的 Podfile 文件中

Carthage

github "shial4/SListView" 这行添加到你的 Cartfile 文件中

手动

克隆仓库并将 SListView 文件夹拖入你的 Xcode 项目中。

Swift Package Manager

.package(url: "https://github.com/shial4/SListView.git", from: "0.0.1"), 这行添加到你的 Package.swift 文件中

在你的 iOS 项目中使用 Swift Package Manager: 本项目演示了一种使用 Swift Package Manager (SPM) 管理 iOS 项目依赖项的工作方法。

如何使用 SPM v4 管理 iOS 依赖项的示例

💊 用法

import UIKit
import SListView

``

Inherit from the `ListViewController`

class CalendarViewController: ListViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        listView.registerClassForListViewCell(CustomListViewCell.self)
        listView.marginForItem = UIEdgeInsets(top: 8, left: 12, bottom: 8, right: 12)
        listView.scrollDirection = .vertical
        listView.reloadData()
    }
    
    override func listView(_ listView: ListView, didChangeDisplayItemAt index: Int, with offset: Int) {
        //Do your stuff here.
    }
    
    override func listView(_ listView: ListView, willDisplay cell: ListViewCell, at index: Int, with offset: Int) {
        guard let cell = cell as? CustomListViewCell else { return }
        //Do your stuff here.
    }
}

或者遵循 ListView 协议

class CalendarViewController: UIViewController, ListViewDelegate, ListViewDatasource {
    @IBOutlet weak var listView: ListView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        listView.registerClassForListViewCell(CalendarMonthViewCell.self)
        listView.marginForItem = UIEdgeInsets(top: 8, left: 12, bottom: 8, right: 12)
        listView.scrollDirection = .vertical
        listView.reloadData()
    }
    
    func listView(_ listView: ListView, didChangeDisplayItemAt index: Int, with offset: Int) {
        //Do your stuff here.
    }
    
    func listView(_ listView: ListView, willDisplay cell: ListViewCell, at index: Int, with offset: Int) {
        guard let cell = cell as? CalendarMonthViewCell else { return }
        //Do your stuff here.
    }
}

⭐ 贡献

欢迎为本项目做贡献! :)

❓ 问题

只需在 GitHub 上创建一个 issue。

📝 许可证

本项目根据 MIT 许可证发布。