📊 A lightweight, flexible UICollectionViewFlowLayout subclass for easily aligning cells per section with optional row limits.
- Configure a single alignment for all sections, or use closures for section-specific logic.
- Optionally limit the number of rows per section.
- Integrates seamlessly with Interface Builder or programmatically.
// 1. Single static alignment for all sections
collectionView.collectionViewLayout =SSAlignmentFlowLayout(alignment:.left)
// 2. Dynamic alignment & row limit via closures (safe of retain cycles)
collectionView.collectionViewLayout =SSAlignmentFlowLayout(
alignmentProvider:{[weak self] section inguardlet self else{return.left }returnself.alignment(for: section)},
limitOfRowsProvider:{ section in
section ==0?2:0})SSAlignmentFlowLayout is available via Swift Package Manager.
- Open your project in Xcode
- Go to File > Add Packages…
- Enter the URL:
https://github.com/dSunny90/SSAlignmentFlowLayout
- Select the version and finish
dependencies:[.package(url:"https://github.com/dSunny90/SSAlignmentFlowLayout", from:"1.0.0")]