Bump version to 3.0.0
Generic reusables for Cocoa. Currently supports UITableView and UICollectionView.
UITableView
UICollectionView
collectionView.register(UserCell.self, forCellWithReuseIdentifier: "userCell") collectionView.dequeueReusableCell(withReuseIdentifier: "userCell", for: indexPath) as! UserCell
let reusableUserCell = ReusableCell<UserCell>() collectionView.register(reusableUserCell) collectionView.dequeue(reusableUserCell) // UserCell
It is recommended to define reusable types as a static constants in an enum or a struct.
enum
struct
// 1. define enum Reusable { static let headerView = ReusableCell<SectionHeaderView>() static let userCell = ReusableCell<UserCell>() } // 2. register tableView.register(Reusable.headerView) tableView.register(Reusable.userCell) // 3. dequeue tableView.dequeue(Reusable.headerView, for: indexPath) tableView.dequeue(Reusable.userCell, for: indexPath)
// 1. define enum Reusable { static let headerView = ReusableCell<SectionHeaderView>() static let photoCell = ReusableCell<PhotoCell>() } // 2. register collection.register(Reusable.headerView, kind: .header) collection.register(Reusable.photoCell) // 3. dequeue collection.dequeue(Reusable.headerView, kind: .header, for: indexPath) collection.dequeue(Reusable.photoCell, for: indexPath)
ReusableKit supports a RxSwift extension.
users // Observable<[String]> .bind(to: collectionView.rx.items(Reusable.userCell)) { i, user, cell in cell.user = user }
Pull requests are welcomed 💖
In order to create Xcode project, run:
$ swift package generate-xcodeproj
For iOS 8+ projects with CocoaPods:
pod 'ReusableKit' pod 'ReusableKit/RxSwift' # with RxSwift extension
ReusableKit is under MIT license. See the LICENSE file for more info.
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
ReusableKit
Generic reusables for Cocoa. Currently supports
UITableView
andUICollectionView
.At a Glance
Before 🤢
After 😊
Example Usage
It is recommended to define reusable types as a static constants in an
enum
or astruct
.UITableView
UICollectionView
RxSwift Extension
ReusableKit supports a RxSwift extension.
Contrubiting
Pull requests are welcomed 💖
In order to create Xcode project, run:
Installation
For iOS 8+ projects with CocoaPods:
License
ReusableKit is under MIT license. See the LICENSE file for more info.