File tree Expand file tree Collapse file tree
Sources/SSAlignmentFlowLayout Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# SSAlignmentFlowLayout
2- A layout object that organizes items with specific alignment, fixed spacing.
2+
3+ 📊 A lightweight, flexible ` UICollectionViewFlowLayout ` subclass for easily aligning cells per section with optional row limits.
4+
5+ [ ![ SwiftPM compatible] ( https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg )] ( https://swift.org/package-manager/ ) ![ Swift] ( https://img.shields.io/badge/Swift-5.7-orange.svg ) ![ Platform] ( https://img.shields.io/badge/platform-iOS%2012-brightgreen ) [ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow.svg )] ( LICENSE )
6+
7+ ---
8+
9+ ## Features
10+
11+ - Configure a single alignment for all sections, or use closures for section-specific logic.
12+ - Optionally limit the number of rows per section.
13+ - Integrates seamlessly with Interface Builder or programmatically.
14+
15+ ---
16+
17+ ## Usage
18+ ``` swift
19+ // 1. Single static alignment for all sections
20+ collectionView.collectionViewLayout = SSAlignmentFlowLayout (alignment : .left )
21+
22+ // 2. Dynamic alignment & row limit via closures (safe of retain cycles)
23+ collectionView.collectionViewLayout = SSAlignmentFlowLayout (
24+ alignmentProvider : { [weak self ] section in
25+ guard let self else { return .left }
26+ return self .alignment (for : section)
27+ },
28+ limitOfRowsProvider : { section in
29+ section == 0 ? 2 : 0
30+ }
31+ )
32+ ```
33+
34+ ---
35+
36+ ## Installation
37+
38+ SSAlignmentFlowLayout is available via Swift Package Manager.
39+
40+ ### Using Xcode:
41+
42+ 1 . Open your project in Xcode
43+ 2 . Go to File > Add Packages…
44+ 3 . Enter the URL:
45+ ```
46+ https://github.com/dSunny90/SSAlignmentFlowLayout
47+ ```
48+ 4 . Select the version and finish
49+
50+ ### Using Package.swift:
51+ ``` swift
52+ dependencies: [
53+ .package (url : " https://github.com/dSunny90/SSAlignmentFlowLayout" , from : " 1.0.0" )
54+ ]
55+ ```
Original file line number Diff line number Diff line change 1010// 2021.02.24. Bug fixes applied
1111// 2024.06.23. Refactoring - Alignment by section
1212// 2024.10.22. Refactoring - Caches and naming
13+ // 2024.11.05. Refactoring - Add a comment
1314//
1415
1516import UIKit
You can’t perform that action at this time.
0 commit comments