$ show chiahsien/CHTCollectionViewWaterfallLayout
CHTCollectionViewWaterfallLayout is a UICollectionViewLayout subclass that implements a Pinterest-like waterfall layout for iOS and tvOS. It provides a configurable multi-column grid that arranges items of varying heights into the shortest column first, with support for per-section headers, footers, column counts, insets, and spacing. The library is implemented in both Swift and Objective-C, distributed via CocoaPods and Swift Package Manager, and requires iOS 13+ / tvOS 13+. It does not depend on any third-party frameworks and is designed to be a drop-in replacement for UICollectionViewFlowLayout when a waterfall arrangement is desired. The Swift implementation (v1.0.0) is a complete rewrite with modern API conventions and improved type safety.
The LLM identified 1 files worth highlighting for reuse:
The primary Swift implementation of the waterfall layout. It encapsulates all layout logic (column height tracking, item placement, union rects for efficient querying) in a single self-contained class with no external dependencies beyond UIKit. The code demonstrates strong iOS engineering practices: computed properties with didSet invalidation, pixel-accurate floor calculations, clear separation of public configuration and private state, and a well-organized prepare() method. The union rects optimization (batching attributes into groups of 20) is a non-obvious performance technique for large collections. This file could be extracted directly into any iOS project requiring a custom waterfall layout.