- July 26, 2025
- Mins Read
CHTCollectionViewWaterfallLayout is a subclass of UICollectionViewLayout, and it trys to imitate UICollectionViewFlowLayout‘s usage as much as possible.
This layout is inspired by Pinterest.
pod 'CHTCollectionViewWaterfallLayout'
to your Podfile.pod 'CHTCollectionViewWaterfallLayout/ObjC'
is ready for you.github chiahsien/CHTCollectionViewWaterfallLayout
to your Cartfile.dependencies
value of your Package.swift
.
dependencies: [
.package(url: “https://github.com/chiahsien/CHTCollectionViewWaterfallLayout.git”, from: “0.9.9”)
]
Manual
CHTCollectionViewWaterfallLayout.h/m
or CHTCollectionViewWaterfallLayout.swift
to your project.Read the demo codes and CHTCollectionViewWaterfallLayout.h
header file for more information.
Below lists the properties for you to customize the layout. Although they have default values, I strongly recommend you to set up at least the columnCount
property to suit your needs. The itemRenderDirection
property is an enum which decides the order in which your items will be rendered in subsequent rows. For eg. Left-Right | Right-Left | Shortest column filling up first.
@property (nonatomic, assign) NSInteger columnCount;
@property (nonatomic, assign) CGFloat minimumColumnSpacing;
@property (nonatomic, assign) CGFloat minimumInteritemSpacing;
@property (nonatomic, assign) CGFloat headerHeight;
@property (nonatomic, assign) CGFloat footerHeight;
@property (nonatomic, assign) UIEdgeInsets sectionInset;
@property (nonatomic, assign) ItemRenderDirection itemRenderDirection;
Your collection view’s delegate (which often is your view controller) must conforms to CHTCollectionViewDelegateWaterfallLayout
protocol and implements the required method, all you need to do is return the original size of the item:
– (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath;
Please let me know if your app is using this library. I’m glad to put your app on the list 🙂
NavigationKit is a lightweight library which makes SwiftUI navigation super easy to use. 💻 Installation 📦 Swift Package Manager Using Swift Package Manager, add ...
An alternative SwiftUI NavigationView implementing classic stack-based navigation giving also some more control on animations and programmatic navigation. NavigationStack Installation ...
With SwiftUI Router you can power your SwiftUI app with path-based routing. By utilizing a path-based system, navigation in your app becomes ...
This package takes SwiftUI's familiar and powerful NavigationStack API and gives it superpowers, allowing you to use the same API not just ...