Swiftpack.co - ts0l/UIReusableView as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by ts0l.
ts0l/UIReusableView 0.4.0
This library allows you to specify a custom UIKit view as reusable, providing simple shorthand and type-safety for common types like UICollectionViewCell, UITableViewCell, and other views which can be loaded from a storyboard or nib.
⭐️ 1
🕓 2 years ago
iOS
.package(url: "https://github.com/ts0l/UIReusableView.git", from: "0.4.0")

UIReusableView

This library allows you to specify a custom UIKit view as reusable, providing simple shorthand and type-safety for common types like UICollectionViewCell, UITableViewCell, and other views which can be loaded from a storyboard or nib.

Installation

Swift Package Manager

  1. In Xcode, select File > Swift Packages > Add Package Dependency.
  2. Follow the prompts using the URL for this repository.

Usage

1. Conforming

class CustomTableViewCell: UITableViewCell, UIReusableView { }
class CustomCollectionViewCell: UICollectionViewCell, UIReusableView { }

2. Registering

override func viewDidLoad() {
    super.viewDidLoad()
    CustomTableViewCell.register(in: tableView)
}
override func viewDidLoad() {
    super.viewDidLoad()
    CustomCollectionViewCell.register(in: collectionView)
}

3. Dequeuing

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell: CustomTableViewCell = .dequeue(from: tableView, at: indexPath)
    return cell
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell: CustomCollectionViewCell = .dequeue(from: collectionView, at: indexPath)
    return cell
}

GitHub

link
Stars: 1
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics