├── screencast.gif
├── CollectionViewMultiColumnLayout.xcodeproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
├── xcuserdata
│ └── vincent.xcuserdatad
│ │ └── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── CollectionViewMultiColumnLayoutDemo.xcscheme
├── xcshareddata
│ └── xcschemes
│ │ └── CollectionViewMultiColumnLayout.xcscheme
└── project.pbxproj
├── CollectionViewMultiColumnLayout
├── CollectionViewMultiColumnLayout.h
├── Info.plist
└── CollectionViewMultiColumnLayout.swift
├── CollectionViewMultiColumnLayoutTests
├── Info.plist
└── CollectionViewMultiColumnLayoutTests.swift
├── CollectionViewMultiColumnLayoutDemo
├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Info.plist
├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
├── AppDelegate.swift
└── ViewController.swift
├── .gitignore
├── README.md
└── LICENSE
/screencast.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/regexident/CollectionViewMultiColumnLayout/HEAD/screencast.gif
--------------------------------------------------------------------------------
/CollectionViewMultiColumnLayout.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/CollectionViewMultiColumnLayout/CollectionViewMultiColumnLayout.h:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewMultiColumnLayout.h
3 | // CollectionViewMultiColumnLayout
4 | //
5 | // Created by Vincent Esche on 5/18/17.
6 | // Copyright © 2017 Vincent Esche. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for CollectionViewMultiColumnLayout.
12 | FOUNDATION_EXPORT double CollectionViewMultiColumnLayoutVersionNumber;
13 |
14 | //! Project version string for CollectionViewMultiColumnLayout.
15 | FOUNDATION_EXPORT const unsigned char CollectionViewMultiColumnLayoutVersionString[];
16 |
17 | // In this header, you should import all the public headers of your framework using statements like #import
18 |
19 |
20 |
--------------------------------------------------------------------------------
/CollectionViewMultiColumnLayoutTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/CollectionViewMultiColumnLayout/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | $(CURRENT_PROJECT_VERSION)
21 | NSPrincipalClass
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/CollectionViewMultiColumnLayout.xcodeproj/xcuserdata/vincent.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | CollectionViewMultiColumnLayout.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 | CollectionViewMultiColumnLayoutDemo.xcscheme
13 |
14 | orderHint
15 | 1
16 |
17 |
18 | SuppressBuildableAutocreation
19 |
20 | BF3D88D61ECDB5DA00E1AC1B
21 |
22 | primary
23 |
24 |
25 | BF3D88DF1ECDB5DA00E1AC1B
26 |
27 | primary
28 |
29 |
30 | BF3D88F61ECDC6B600E1AC1B
31 |
32 | primary
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/CollectionViewMultiColumnLayoutTests/CollectionViewMultiColumnLayoutTests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewMultiColumnLayoutTests.swift
3 | // CollectionViewMultiColumnLayoutTests
4 | //
5 | // Created by Vincent Esche on 5/18/17.
6 | // Copyright © 2017 Vincent Esche. All rights reserved.
7 | //
8 |
9 | import XCTest
10 | @testable import CollectionViewMultiColumnLayout
11 |
12 | class CollectionViewMultiColumnLayoutTests: XCTestCase {
13 |
14 | override func setUp() {
15 | super.setUp()
16 | // Put setup code here. This method is called before the invocation of each test method in the class.
17 | }
18 |
19 | override func tearDown() {
20 | // Put teardown code here. This method is called after the invocation of each test method in the class.
21 | super.tearDown()
22 | }
23 |
24 | func testExample() {
25 | // This is an example of a functional test case.
26 | // Use XCTAssert and related functions to verify your tests produce the correct results.
27 | }
28 |
29 | func testPerformanceExample() {
30 | // This is an example of a performance test case.
31 | self.measure {
32 | // Put the code you want to measure the time of here.
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/CollectionViewMultiColumnLayoutDemo/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/CollectionViewMultiColumnLayoutDemo/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/CollectionViewMultiColumnLayoutDemo/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/swift
3 |
4 | ### Swift ###
5 | # Xcode
6 | #
7 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
8 |
9 | ## Build generated
10 | build/
11 | DerivedData/
12 |
13 | ## Various settings
14 | *.pbxuser
15 | !default.pbxuser
16 | *.mode1v3
17 | !default.mode1v3
18 | *.mode2v3
19 | !default.mode2v3
20 | *.perspectivev3
21 | !default.perspectivev3
22 | xcuserdata/
23 |
24 | ## Other
25 | *.moved-aside
26 | *.xccheckout
27 | *.xcscmblueprint
28 |
29 | ## Obj-C/Swift specific
30 | *.hmap
31 | *.ipa
32 | *.dSYM.zip
33 | *.dSYM
34 |
35 | ## Playgrounds
36 | timeline.xctimeline
37 | playground.xcworkspace
38 |
39 | # Swift Package Manager
40 | #
41 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
42 | # Packages/
43 | # Package.pins
44 | .build/
45 |
46 | # CocoaPods - Refactored to standalone file
47 |
48 | # Carthage - Refactored to standalone file
49 |
50 | # fastlane
51 | #
52 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
53 | # screenshots whenever they are needed.
54 | # For more information about the recommended setup visit:
55 | # https://docs.fastlane.tools/best-practices/source-control/#source-control
56 |
57 | fastlane/report.xml
58 | fastlane/Preview.html
59 | fastlane/screenshots
60 | fastlane/test_output
61 |
62 | ### Swift.CocoaPods Stack ###
63 | ## CocoaPods GitIgnore Template
64 |
65 | # CocoaPods - Only use to conserve bandwidth / Save time on Pushing
66 | # - Also handy if you have a lage number of dependant pods
67 | # - AS PER https://guides.cocoapods.org/using/using-cocoapods.html NEVER IGONRE THE LOCK FILE
68 | Pods/
69 |
70 | ### Swift.Carthage Stack ###
71 | # Carthage
72 | #
73 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
74 | # Carthage/Checkouts
75 |
76 | Carthage/Build
77 |
78 | # End of https://www.gitignore.io/api/swift
79 |
80 | .DS_Store
81 |
--------------------------------------------------------------------------------
/CollectionViewMultiColumnLayoutDemo/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // CollectionViewMultiColumnLayoutDemo
4 | //
5 | // Created by Vincent Esche on 5/18/17.
6 | // Copyright © 2017 Vincent Esche. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 |
17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
18 | // Override point for customization after application launch.
19 | return true
20 | }
21 |
22 | func applicationWillResignActive(_ application: UIApplication) {
23 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
25 | }
26 |
27 | func applicationDidEnterBackground(_ application: UIApplication) {
28 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30 | }
31 |
32 | func applicationWillEnterForeground(_ application: UIApplication) {
33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
34 | }
35 |
36 | func applicationDidBecomeActive(_ application: UIApplication) {
37 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
38 | }
39 |
40 | func applicationWillTerminate(_ application: UIApplication) {
41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42 | }
43 |
44 |
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CollectionViewMultiColumnLayout
2 |
3 | **CollectionViewMultiColumnLayout** is a `UICollectionViewLayout` that resembles a tiled waterfall/mosaic layout (as seen all over the web), with support of multiple columns per section and explicitly assigning a section's items to specific columns:
4 |
5 | 
6 |
7 | ## Usage
8 |
9 | ```swift
10 | import CollectionViewMultiColumnLayout
11 |
12 | class CollectionViewController: UICollectionViewController {
13 |
14 | // ...
15 |
16 | override func viewDidLoad() {
17 | super.viewDidLoad()
18 | let layout = CollectionViewMultiColumnLayout()
19 | collectionView.setCollectionViewLayout(layout, animated: false)
20 | }
21 | }
22 |
23 | extension CollectionViewController: CollectionViewMultiColumnLayoutDataSource {
24 |
25 | func collectionView(_ collectionView: UICollectionView, numberOfColumnsInSection section: Int) -> Int {
26 | // ...
27 | }
28 |
29 | func collectionView(_ collectionView: UICollectionView, columnForItemAt indexPath: NSIndexPath) -> Int? {
30 | // ...
31 | }
32 | }
33 |
34 | extension CollectionViewController: CollectionViewMultiColumnLayoutDelegate {
35 |
36 | func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
37 | // ...
38 | }
39 |
40 | // Optional methods:
41 |
42 | func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, heightForHeaderInSection section: Int) -> CGFloat {
43 | // ...
44 | }
45 |
46 | func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, heightForFooterInSection section: Int) -> CGFloat {
47 | // ...
48 | }
49 |
50 | func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, insetForSection section: Int) -> UIEdgeInsets {
51 | // ...
52 | }
53 |
54 | func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, insetForHeaderInSection section: Int) -> UIEdgeInsets {
55 | // ...
56 | }
57 |
58 | func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, insetForFooterInSection section: Int) -> UIEdgeInsets {
59 | // ...
60 | }
61 |
62 | func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, minimumInteritemSpacingForSection section: Int) -> CGFloat {
63 | // ...
64 | }
65 | }
66 | ```
67 |
68 | ## Installation
69 |
70 | The recommended way to add **CollectionViewMultiColumnLayout** to your project is via [Carthage](https://github.com/Carthage/Carthage):
71 |
72 | github 'regexident/CollectionViewMultiColumnLayout'
73 |
74 | ## License
75 |
76 | **CollectionViewMultiColumnLayout** is available under the **MPL-2 license**. See the `LICENSE` file for more info.
77 |
--------------------------------------------------------------------------------
/CollectionViewMultiColumnLayoutDemo/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/CollectionViewMultiColumnLayout.xcodeproj/xcuserdata/vincent.xcuserdatad/xcschemes/CollectionViewMultiColumnLayoutDemo.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/CollectionViewMultiColumnLayout.xcodeproj/xcshareddata/xcschemes/CollectionViewMultiColumnLayout.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
49 |
50 |
51 |
52 |
53 |
54 |
64 |
65 |
71 |
72 |
73 |
74 |
75 |
76 |
82 |
83 |
89 |
90 |
91 |
92 |
94 |
95 |
98 |
99 |
100 |
--------------------------------------------------------------------------------
/CollectionViewMultiColumnLayoutDemo/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // CollectionViewMultiColumnLayoutDemo
4 | //
5 | // Created by Vincent Esche on 5/18/17.
6 | // Copyright © 2017 Vincent Esche. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | import CollectionViewMultiColumnLayout
12 |
13 | class CollectionViewController: UICollectionViewController {
14 |
15 | enum ReuseIdentifier: String {
16 | case cell = "Cell"
17 | case headerReuseIdentifier = "Header"
18 | case footerReuseIdentifier = "Footer"
19 | }
20 | fileprivate static let cellReuseIdentifier = "Cell"
21 | fileprivate static let headerReuseIdentifier = "Header"
22 | fileprivate static let footerReuseIdentifier = "Footer"
23 |
24 | override func viewDidLoad() {
25 | super.viewDidLoad()
26 |
27 | // Uncomment the following line to preserve selection between presentations
28 | // self.clearsSelectionOnViewWillAppear = false
29 |
30 | guard let collectionView = self.collectionView else {
31 | return
32 | }
33 |
34 | // Register cell classes
35 | collectionView.register(
36 | UICollectionViewCell.self,
37 | forCellWithReuseIdentifier: CollectionViewController.cellReuseIdentifier
38 | )
39 | collectionView.register(
40 | UICollectionReusableView.self,
41 | forSupplementaryViewOfKind: UICollectionElementKindSectionHeader,
42 | withReuseIdentifier: CollectionViewController.headerReuseIdentifier
43 | )
44 | collectionView.register(
45 | UICollectionReusableView.self,
46 | forSupplementaryViewOfKind: UICollectionElementKindSectionFooter,
47 | withReuseIdentifier: CollectionViewController.footerReuseIdentifier
48 | )
49 |
50 | let layout = CollectionViewMultiColumnLayout()
51 | collectionView.setCollectionViewLayout(layout, animated: false)
52 |
53 | // Do any additional setup after loading the view.
54 | }
55 | }
56 |
57 | extension CollectionViewController /*: UICollectionViewDataSource */ {
58 |
59 | override func numberOfSections(in collectionView: UICollectionView) -> Int {
60 | return 3
61 | }
62 |
63 | override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
64 | switch section {
65 | case 0: return 2
66 | case 1: return 4
67 | case 2: return 5
68 | case _: return 0
69 | }
70 | }
71 |
72 | override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
73 | let cell = collectionView.dequeueReusableCell(
74 | withReuseIdentifier: CollectionViewController.cellReuseIdentifier,
75 | for: indexPath
76 | )
77 |
78 | let column = self.collectionView(collectionView, columnForItemAt: indexPath as NSIndexPath)!
79 | cell.backgroundColor = [.darkGray, .gray, .lightGray][column % 3]
80 |
81 | return cell
82 | }
83 |
84 | override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
85 |
86 | let reuseIdentifier: String = {
87 | switch kind {
88 | case UICollectionElementKindSectionHeader:
89 | return CollectionViewController.headerReuseIdentifier
90 | case UICollectionElementKindSectionFooter:
91 | return CollectionViewController.footerReuseIdentifier
92 | case _: fatalError("Unrecognized UICollectionElementKind: '\(kind)'")
93 | }
94 | }()
95 |
96 | let supplementaryView = collectionView.dequeueReusableSupplementaryView(
97 | ofKind: kind,
98 | withReuseIdentifier: reuseIdentifier,
99 | for: indexPath
100 | )
101 |
102 | // Configure the cell
103 |
104 | switch kind {
105 | case UICollectionElementKindSectionHeader:
106 | supplementaryView.backgroundColor = .blue
107 | case UICollectionElementKindSectionFooter:
108 | supplementaryView.backgroundColor = .green
109 | case _: break
110 | }
111 |
112 | return supplementaryView
113 | }
114 |
115 | // MARK: UICollectionViewDelegate
116 |
117 | /*
118 | // Uncomment this method to specify if the specified item should be highlighted during tracking
119 | override func collectionView(_ collectionView: UICollectionView, shouldHighlightItemAt indexPath: IndexPath) -> Bool {
120 | return true
121 | }
122 | */
123 |
124 | /*
125 | // Uncomment this method to specify if the specified item should be selected
126 | override func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool {
127 | return true
128 | }
129 | */
130 |
131 | /*
132 | // Uncomment these methods to specify if an action menu should be displayed for the specified item, and react to actions performed on the item
133 | override func collectionView(_ collectionView: UICollectionView, shouldShowMenuForItemAt indexPath: IndexPath) -> Bool {
134 | return false
135 | }
136 |
137 | override func collectionView(_ collectionView: UICollectionView, canPerformAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) -> Bool {
138 | return false
139 | }
140 |
141 | override func collectionView(_ collectionView: UICollectionView, performAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) {
142 |
143 | }
144 | */
145 |
146 | }
147 |
148 | extension CollectionViewController: CollectionViewMultiColumnLayoutDataSource {
149 |
150 | func collectionView(_ collectionView: UICollectionView, numberOfColumnsInSection section: Int) -> Int {
151 | switch section {
152 | case 0: return 1
153 | case 1: return 2
154 | case 2: return 3
155 | case _: return 0
156 | }
157 | }
158 |
159 | func collectionView(_ collectionView: UICollectionView, columnForItemAt indexPath: NSIndexPath) -> Int? {
160 | return indexPath.item % (indexPath.section + 1)
161 | }
162 | }
163 |
164 | extension CollectionViewController: CollectionViewMultiColumnLayoutDelegate {
165 |
166 | func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
167 | let height = CGFloat(arc4random_uniform(20)) + 10.0
168 | return CGSize(width: 30.0, height: height)
169 | }
170 |
171 | func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, heightForHeaderInSection section: Int) -> CGFloat {
172 | return 0.0
173 | }
174 |
175 | func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, heightForFooterInSection section: Int) -> CGFloat {
176 | return 0.0
177 | }
178 |
179 | func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, insetForSection section: Int) -> UIEdgeInsets {
180 | return UIEdgeInsets(top: 10.0, left: 10.0, bottom: 10.0, right: 10.0)
181 | }
182 |
183 | // func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, insetForHeaderInSection section: Int) -> UIEdgeInsets
184 | // func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, insetForFooterInSection section: Int) -> UIEdgeInsets
185 |
186 | func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, minimumInteritemSpacingForSection section: Int) -> CGFloat {
187 | return 10.0
188 | }
189 | }
190 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Mozilla Public License, version 2.0 1. Definitions 1.1. “Contributor” means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software.
2 |
3 | 1.2. “Contributor Version” means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor’s Contribution.
4 |
5 | 1.3. “Contribution” means Covered Software of a particular Contributor.
6 |
7 | 1.4. “Covered Software” means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof.
8 |
9 | 1.5. “Incompatible With Secondary Licenses” means
10 |
11 | that the initial Contributor has attached the notice described in Exhibit B to the Covered Software; or
12 |
13 | that the Covered Software was made available under the terms of version 1.1 or earlier of the License, but not also under the terms of a Secondary License.
14 |
15 | 1.6. “Executable Form” means any form of the work other than Source Code Form.
16 |
17 | 1.7. “Larger Work” means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software.
18 |
19 | 1.8. “License” means this document.
20 |
21 | 1.9. “Licensable” means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License.
22 |
23 | 1.10. “Modifications” means any of the following:
24 |
25 | any file in Source Code Form that results from an addition to, deletion from, or modification of the contents of Covered Software; or
26 |
27 | any new file in Source Code Form that contains any Covered Software.
28 |
29 | 1.11. “Patent Claims” of a Contributor means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the License, by the making, using, selling, offering for sale, having made, import, or transfer of either its Contributions or its Contributor Version.
30 |
31 | 1.12. “Secondary License” means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses.
32 |
33 | 1.13. “Source Code Form” means the form of the work preferred for making modifications.
34 |
35 | 1.14. “You” (or “Your”) means an individual or a legal entity exercising rights under this License. For legal entities, “You” includes any entity that controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity.
36 |
37 | 2. License Grants and Conditions 2.1. Grants Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license:
38 |
39 | under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and
40 |
41 | under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version.
42 |
43 | 2.2. Effective Date The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution.
44 |
45 | 2.3. Limitations on Grant Scope The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor:
46 |
47 | for any code that a Contributor has removed from Covered Software; or
48 |
49 | for infringements caused by: (i) Your and any other third party’s modifications of Covered Software, or (ii) the combination of its Contributions with other software (except as part of its Contributor Version); or
50 |
51 | under Patent Claims infringed by Covered Software in the absence of its Contributions.
52 |
53 | This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4).
54 |
55 | 2.4. Subsequent Licenses No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3).
56 |
57 | 2.5. Representation Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License.
58 |
59 | 2.6. Fair Use This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents.
60 |
61 | 2.7. Conditions Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1.
62 |
63 | 3. Responsibilities 3.1. Distribution of Source Form All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under the terms of this License. You must inform recipients that the Source Code Form of the Covered Software is governed by the terms of this License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients’ rights in the Source Code Form.
64 |
65 | 3.2. Distribution of Executable Form If You distribute Covered Software in Executable Form then:
66 |
67 | such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and
68 |
69 | You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients’ rights in the Source Code Form under this License.
70 |
71 | 3.3. Distribution of a Larger Work You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for the Covered Software. If the Larger Work is a combination of Covered Software with a work governed by one or more Secondary Licenses, and the Covered Software is not Incompatible With Secondary Licenses, this License permits You to additionally distribute such Covered Software under the terms of such Secondary License(s), so that the recipient of the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s).
72 |
73 | 3.4. Notices You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies.
74 |
75 | 3.5. Application of Additional Terms You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, You may do so only on Your own behalf, and not on behalf of any Contributor. You must make it absolutely clear that any such warranty, support, indemnity, or liability obligation is offered by You alone, and You hereby agree to indemnify every Contributor for any liability incurred by such Contributor as a result of warranty, support, indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction.
76 |
77 | 4. Inability to Comply Due to Statute or Regulation If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it.
78 |
79 | 5. Termination 5.1. The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular Contributor are reinstated (a) provisionally, unless and until such Contributor explicitly and finally terminates Your grants, and (b) on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular Contributor are reinstated on an ongoing basis if such Contributor notifies You of the non-compliance by some reasonable means, this is the first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice.
80 |
81 | 5.2. If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate.
82 |
83 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination.
84 |
85 | 6. Disclaimer of Warranty Covered Software is provided under this License on an “as is” basis, without warranty of any kind, either expressed, implied, or statutory, including, without limitation, warranties that the Covered Software is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire risk as to the quality and performance of the Covered Software is with You. Should any Covered Software prove defective in any respect, You (not any Contributor) assume the cost of any necessary servicing, repair, or correction. This disclaimer of warranty constitutes an essential part of this License. No use of any Covered Software is authorized under this License except under this disclaimer.
86 |
87 | 7. Limitation of Liability Under no circumstances and under no legal theory, whether tort (including negligence), contract, or otherwise, shall any Contributor, or anyone who distributes Covered Software as permitted above, be liable to You for any direct, indirect, special, incidental, or consequential damages of any character including, without limitation, damages for lost profits, loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses, even if such party shall have been informed of the possibility of such damages. This limitation of liability shall not apply to liability for death or personal injury resulting from such party’s negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You.
88 |
89 | 8. Litigation Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business and such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party’s ability to bring cross-claims or counter-claims.
90 |
91 | 9. Miscellaneous This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor.
92 |
93 | 10. Versions of the License 10.1. New Versions Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number.
94 |
95 | 10.2. Effect of New Versions You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward.
96 |
97 | 10.3. Modified Versions If you create software not governed by this License, and you want to create a new license for such software, you may create and use a modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License).
98 |
99 | 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached.
100 |
101 | Exhibit A - Source Code Form License Notice This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
102 |
103 | If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice.
104 |
105 | You may add additional accurate notices of copyright ownership.
106 |
107 | Exhibit B - “Incompatible With Secondary Licenses” Notice This Source Code Form is “Incompatible With Secondary Licenses”, as defined by the Mozilla Public License, v. 2.0.
108 |
--------------------------------------------------------------------------------
/CollectionViewMultiColumnLayout/CollectionViewMultiColumnLayout.swift:
--------------------------------------------------------------------------------
1 | //
2 | // CollectionViewMultiColumnLayout.swift
3 | // CollectionViewMultiColumnLayout
4 | //
5 | // Created by Vincent Esche on 5/18/17.
6 | // Copyright © 2017 Vincent Esche. All rights reserved.
7 | //
8 | // This Source Code Form is subject to the terms of the Mozilla Public
9 | // License, v. 2.0. If a copy of the MPL was not distributed with this
10 | // file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 | //
12 | // Based on https://github.com/chiahsien/CHTCollectionViewWaterfallLayout (MIT License)
13 |
14 | import UIKit
15 |
16 | public protocol CollectionViewMultiColumnLayoutDataSource: UICollectionViewDataSource {
17 |
18 | func collectionView(
19 | _ collectionView: UICollectionView,
20 | numberOfColumnsInSection section: Int
21 | ) -> Int
22 |
23 | func collectionView(
24 | _ collectionView: UICollectionView,
25 | columnForItemAt indexPath: NSIndexPath
26 | ) -> Int?
27 | }
28 |
29 | @objc public protocol CollectionViewMultiColumnLayoutDelegate: UICollectionViewDelegate {
30 |
31 | func collectionView(
32 | _ collectionView: UICollectionView,
33 | layout: UICollectionViewLayout,
34 | sizeForItemAtIndexPath indexPath: NSIndexPath
35 | ) -> CGSize
36 |
37 | @objc optional func collectionView(
38 | _ collectionView: UICollectionView,
39 | layout: UICollectionViewLayout,
40 | heightForHeaderInSection section: Int
41 | ) -> CGFloat
42 |
43 | @objc optional func collectionView(
44 | _ collectionView: UICollectionView,
45 | layout: UICollectionViewLayout,
46 | heightForFooterInSection section: Int
47 | ) -> CGFloat
48 |
49 | @objc optional func collectionView(
50 | _ collectionView: UICollectionView,
51 | layout: UICollectionViewLayout,
52 | minimumInteritemSpacingForSection section: Int
53 | ) -> CGFloat
54 |
55 | @objc optional func collectionView(
56 | _ collectionView: UICollectionView,
57 | layout: UICollectionViewLayout,
58 | insetForSection section: Int
59 | ) -> UIEdgeInsets
60 |
61 | @objc optional func collectionView(
62 | _ collectionView: UICollectionView,
63 | layout: UICollectionViewLayout,
64 | insetForHeaderInSection section: Int
65 | ) -> UIEdgeInsets
66 |
67 | @objc optional func collectionView(
68 | _ collectionView: UICollectionView,
69 | layout: UICollectionViewLayout,
70 | insetForFooterInSection section: Int
71 | ) -> UIEdgeInsets
72 | }
73 |
74 | public class CollectionViewMultiColumnLayout: UICollectionViewLayout {
75 |
76 | /// How many items to be union into a single rectangle
77 | private let unionSize = 20;
78 |
79 | public var minimumColumnSpacing: CGFloat = 10.0 {
80 | didSet {
81 | self.invalidateIfNecessary(old: oldValue, new: self.minimumColumnSpacing)
82 | }
83 | }
84 |
85 | public var minimumInteritemSpacing: CGFloat = 10.0 {
86 | didSet {
87 | self.invalidateIfNecessary(old: oldValue, new: self.minimumInteritemSpacing)
88 | }
89 | }
90 |
91 | public var headerHeight: CGFloat = 0.0 {
92 | didSet {
93 | self.invalidateIfNecessary(old: oldValue, new: self.headerHeight)
94 | }
95 | }
96 |
97 | public var footerHeight: CGFloat = 0.0 {
98 | didSet {
99 | self.invalidateIfNecessary(old: oldValue, new: self.footerHeight)
100 | }
101 | }
102 |
103 | public var headerInsets: UIEdgeInsets = .zero {
104 | didSet {
105 | self.invalidateIfNecessary(old: oldValue, new: self.headerInsets)
106 | }
107 | }
108 |
109 | public var footerInsets: UIEdgeInsets = .zero {
110 | didSet {
111 | self.invalidateIfNecessary(old: oldValue, new: self.footerInsets)
112 | }
113 | }
114 |
115 | public var sectionInsets: UIEdgeInsets = .zero {
116 | didSet {
117 | self.invalidateIfNecessary(old: oldValue, new: self.sectionInsets)
118 | }
119 | }
120 |
121 | private var dataSource: CollectionViewMultiColumnLayoutDataSource? {
122 | guard let defaultDataSource = self.collectionView?.delegate else {
123 | return nil
124 | }
125 | guard let dataSource = defaultDataSource as? CollectionViewMultiColumnLayoutDataSource else {
126 | let name = String(describing: CollectionViewMultiColumnLayoutDataSource.self)
127 | print("UICollectionView's dataSource should conform to \(name) protocol")
128 | return nil
129 | }
130 | return dataSource
131 | }
132 |
133 | private var delegate: CollectionViewMultiColumnLayoutDelegate? {
134 | guard let defaultDelegate = self.collectionView?.delegate else {
135 | return nil
136 | }
137 | guard let delegate = defaultDelegate as? CollectionViewMultiColumnLayoutDelegate else {
138 | let name = String(describing: CollectionViewMultiColumnLayoutDelegate.self)
139 | print("UICollectionView's delegate should conform to \(name) protocol")
140 | return nil
141 | }
142 | return delegate
143 | }
144 |
145 | private var sectionItemAttributes: [[UICollectionViewLayoutAttributes]] = []
146 | private var allItemAttributes: [UICollectionViewLayoutAttributes] = []
147 | private var headersAttribute: [Int : UICollectionViewLayoutAttributes] = [:]
148 | private var footersAttribute: [Int : UICollectionViewLayoutAttributes] = [:]
149 | private var sectionRects: [Int : CGRect] = [:]
150 | private var contentHeight: CGFloat = 0.0
151 |
152 | override public func prepare() {
153 | super.prepare()
154 |
155 | guard let collectionView = self.collectionView else {
156 | return
157 | }
158 |
159 | guard let delegate = self.delegate else {
160 | return
161 | }
162 |
163 | guard let dataSource = self.dataSource else {
164 | return
165 | }
166 |
167 | self.headersAttribute.removeAll(keepingCapacity: false)
168 | self.footersAttribute.removeAll(keepingCapacity: false)
169 | self.sectionRects.removeAll(keepingCapacity: false)
170 | self.allItemAttributes.removeAll(keepingCapacity: false)
171 | self.sectionItemAttributes.removeAll(keepingCapacity: false)
172 |
173 | let numberOfSections = collectionView.numberOfSections
174 | guard numberOfSections > 0 else {
175 | return;
176 | }
177 |
178 | var top: CGFloat = 0.0
179 | var attributes: UICollectionViewLayoutAttributes
180 |
181 | var contentHeight: CGFloat = 0.0
182 |
183 | for section in 0.. 0, "Number of columns should be greater than 0.")
189 |
190 | var columnHeights: [CGFloat] = Array(repeating: 0.0, count: numberOfColumns)
191 |
192 | var sectionRect: CGRect = .null
193 |
194 | // MARK: Section metrics
195 |
196 | let minimumInteritemSpacing = delegate.collectionView?(
197 | collectionView,
198 | layout: self,
199 | minimumInteritemSpacingForSection: section
200 | ) ?? self.minimumInteritemSpacing
201 |
202 | let sectionInsets = delegate.collectionView?(
203 | collectionView,
204 | layout: self,
205 | insetForSection: section
206 | ) ?? self.sectionInsets
207 |
208 | let width = collectionView.frame.width - sectionInsets.left - sectionInsets.right
209 | let columnSpacing = (CGFloat(numberOfColumns) - 1.0) * self.minimumColumnSpacing
210 | let itemWidth = floor((width - columnSpacing) / CGFloat(numberOfColumns))
211 |
212 | // MARK: Section header
213 |
214 | let headerHeight = delegate.collectionView?(
215 | collectionView,
216 | layout: self,
217 | heightForHeaderInSection: section
218 | ) ?? self.headerHeight
219 |
220 | let headerInsets = delegate.collectionView?(
221 | collectionView,
222 | layout: self,
223 | insetForHeaderInSection: section
224 | ) ?? self.headerInsets
225 |
226 | top += headerInsets.top
227 |
228 | if headerHeight > 0 {
229 | let indexPath = IndexPath(item: 0, section: section)
230 | attributes = UICollectionViewLayoutAttributes(
231 | forSupplementaryViewOfKind: UICollectionElementKindSectionHeader,
232 | with: indexPath
233 | )
234 | attributes.frame = CGRect(
235 | x: headerInsets.left,
236 | y: top,
237 | width: collectionView.frame.width - (headerInsets.left + headerInsets.right),
238 | height: headerHeight
239 | )
240 | self.headersAttribute[section] = attributes
241 | sectionRect = sectionRect.union(attributes.frame)
242 | top = attributes.frame.maxY + headerInsets.bottom
243 | }
244 |
245 | top += sectionInsets.top
246 | for idx in 0.. 0 && itemSize.width > 0 {
273 | itemHeight = itemSize.height * itemWidth / itemSize.width
274 | }
275 |
276 | attributes = UICollectionViewLayoutAttributes(forCellWith: indexPath)
277 | attributes.frame = CGRect(
278 | origin: CGPoint(x: xOffset, y: yOffset),
279 | size: CGSize(width: itemWidth, height: itemHeight)
280 | )
281 | itemAttributes.append(attributes)
282 | self.allItemAttributes.append(attributes)
283 | sectionRect = sectionRect.union(attributes.frame)
284 | columnHeights[column] = attributes.frame.maxY + minimumInteritemSpacing
285 | }
286 |
287 | self.sectionItemAttributes.append(itemAttributes)
288 |
289 | // MARK: Section footer
290 |
291 | let columnIndex = longestColumnIndex(columnHeights)
292 | top = columnHeights[columnIndex] - minimumInteritemSpacing + sectionInsets.bottom
293 |
294 | let footerHeight = delegate.collectionView?(
295 | collectionView,
296 | layout: self,
297 | heightForFooterInSection: section
298 | ) ?? self.footerHeight
299 |
300 | let footerInsets = delegate.collectionView?(
301 | collectionView,
302 | layout: self,
303 | insetForFooterInSection: section
304 | ) ?? self.footerInsets
305 |
306 | top += footerInsets.top
307 |
308 | if footerHeight > 0 {
309 | let indexPath = IndexPath(item: 0, section: section)
310 | attributes = UICollectionViewLayoutAttributes(
311 | forSupplementaryViewOfKind: UICollectionElementKindSectionFooter,
312 | with: indexPath
313 | )
314 | attributes.frame = CGRect(
315 | x: footerInsets.left,
316 | y: top,
317 | width: collectionView.frame.width - (footerInsets.left + footerInsets.right),
318 | height: footerHeight
319 | )
320 | self.footersAttribute[section] = attributes
321 | self.allItemAttributes.append(attributes)
322 | sectionRect = sectionRect.union(attributes.frame)
323 | top = attributes.frame.maxY + footerInsets.bottom
324 | }
325 |
326 | contentHeight = top
327 | self.sectionRects[section] = sectionRect
328 | }
329 |
330 | self.contentHeight = contentHeight
331 | }
332 |
333 | override public var collectionViewContentSize: CGSize {
334 | guard let collectionView = self.collectionView else {
335 | return .zero
336 | }
337 | guard collectionView.numberOfSections > 0 else {
338 | return .zero
339 | }
340 | var contentSize = collectionView.bounds.size
341 | contentSize.height = self.contentHeight
342 | return contentSize
343 | }
344 |
345 | override public func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
346 | guard indexPath.section < self.sectionItemAttributes.count else {
347 | return nil
348 | }
349 | guard indexPath.item < self.sectionItemAttributes[indexPath.section].count else {
350 | return nil
351 | }
352 | return self.sectionItemAttributes[indexPath.section][indexPath.item]
353 | }
354 |
355 | override public func layoutAttributesForSupplementaryView(
356 | ofKind elementKind: String,
357 | at indexPath: IndexPath
358 | ) -> UICollectionViewLayoutAttributes? {
359 | switch elementKind {
360 | case UICollectionElementKindSectionHeader:
361 | return self.headersAttribute[indexPath.section]
362 | case UICollectionElementKindSectionFooter:
363 | return self.footersAttribute[indexPath.section]
364 | case _:
365 | return nil
366 | }
367 | }
368 |
369 | override public func layoutAttributesForElements(
370 | in rect: CGRect
371 | ) -> [UICollectionViewLayoutAttributes] {
372 | return Array(self.sectionRects.lazy.flatMap { section, sectionRect in
373 | sectionRect.intersects(rect) ? self.sectionItemAttributes[section] : nil
374 | }.joined())
375 | }
376 |
377 | override public func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool {
378 | guard let collectionView = self.collectionView else {
379 | return false
380 | }
381 | let oldBounds = collectionView.bounds
382 | if newBounds.width != oldBounds.width {
383 | return true
384 | }
385 | return false
386 | }
387 |
388 | private func shortestColumnIndex(_ columnHeights: [CGFloat]) -> Int {
389 | return columnHeights.enumerated().min { $0.1 < $1.1 }!.0
390 | }
391 |
392 | private func longestColumnIndex(_ columnHeights: [CGFloat]) -> Int {
393 | return columnHeights.enumerated().max { $0.1 < $1.1 }!.0
394 | }
395 |
396 | private func invalidateIfNecessary(old: T, new: T) where T: Equatable {
397 | if old != new {
398 | self.invalidateLayout()
399 | }
400 | }
401 | }
402 |
--------------------------------------------------------------------------------
/CollectionViewMultiColumnLayout.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | BF3D88E11ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayout.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF3D88D71ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayout.framework */; };
11 | BF3D88E61ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayoutTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3D88E51ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayoutTests.swift */; };
12 | BF3D88E81ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = BF3D88DA1ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayout.h */; settings = {ATTRIBUTES = (Public, ); }; };
13 | BF3D88F21ECDB5F600E1AC1B /* CollectionViewMultiColumnLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3D88F11ECDB5F600E1AC1B /* CollectionViewMultiColumnLayout.swift */; };
14 | BF3D88FA1ECDC6B600E1AC1B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3D88F91ECDC6B600E1AC1B /* AppDelegate.swift */; };
15 | BF3D88FC1ECDC6B600E1AC1B /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3D88FB1ECDC6B600E1AC1B /* ViewController.swift */; };
16 | BF3D88FF1ECDC6B600E1AC1B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BF3D88FD1ECDC6B600E1AC1B /* Main.storyboard */; };
17 | BF3D89011ECDC6B600E1AC1B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BF3D89001ECDC6B600E1AC1B /* Assets.xcassets */; };
18 | BF3D89041ECDC6B600E1AC1B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = BF3D89021ECDC6B600E1AC1B /* LaunchScreen.storyboard */; };
19 | BF3D890C1ECDC71800E1AC1B /* CollectionViewMultiColumnLayout.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF3D88D71ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayout.framework */; };
20 | BF3D890D1ECDC71800E1AC1B /* CollectionViewMultiColumnLayout.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = BF3D88D71ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayout.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
21 | /* End PBXBuildFile section */
22 |
23 | /* Begin PBXContainerItemProxy section */
24 | BF3D88E21ECDB5DA00E1AC1B /* PBXContainerItemProxy */ = {
25 | isa = PBXContainerItemProxy;
26 | containerPortal = BF3D88CE1ECDB5DA00E1AC1B /* Project object */;
27 | proxyType = 1;
28 | remoteGlobalIDString = BF3D88D61ECDB5DA00E1AC1B;
29 | remoteInfo = CollectionViewMultiColumnLayout;
30 | };
31 | BF3D89091ECDC70700E1AC1B /* PBXContainerItemProxy */ = {
32 | isa = PBXContainerItemProxy;
33 | containerPortal = BF3D88CE1ECDB5DA00E1AC1B /* Project object */;
34 | proxyType = 1;
35 | remoteGlobalIDString = BF3D88D61ECDB5DA00E1AC1B;
36 | remoteInfo = CollectionViewMultiColumnLayout;
37 | };
38 | /* End PBXContainerItemProxy section */
39 |
40 | /* Begin PBXCopyFilesBuildPhase section */
41 | BF3D890E1ECDC71800E1AC1B /* Embed Frameworks */ = {
42 | isa = PBXCopyFilesBuildPhase;
43 | buildActionMask = 2147483647;
44 | dstPath = "";
45 | dstSubfolderSpec = 10;
46 | files = (
47 | BF3D890D1ECDC71800E1AC1B /* CollectionViewMultiColumnLayout.framework in Embed Frameworks */,
48 | );
49 | name = "Embed Frameworks";
50 | runOnlyForDeploymentPostprocessing = 0;
51 | };
52 | /* End PBXCopyFilesBuildPhase section */
53 |
54 | /* Begin PBXFileReference section */
55 | BF3D88D71ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayout.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CollectionViewMultiColumnLayout.framework; sourceTree = BUILT_PRODUCTS_DIR; };
56 | BF3D88DA1ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CollectionViewMultiColumnLayout.h; sourceTree = ""; };
57 | BF3D88DB1ECDB5DA00E1AC1B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
58 | BF3D88E01ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayoutTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CollectionViewMultiColumnLayoutTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
59 | BF3D88E51ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayoutTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionViewMultiColumnLayoutTests.swift; sourceTree = ""; };
60 | BF3D88E71ECDB5DA00E1AC1B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
61 | BF3D88F11ECDB5F600E1AC1B /* CollectionViewMultiColumnLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionViewMultiColumnLayout.swift; sourceTree = ""; };
62 | BF3D88F71ECDC6B600E1AC1B /* CollectionViewMultiColumnLayoutDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CollectionViewMultiColumnLayoutDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
63 | BF3D88F91ECDC6B600E1AC1B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
64 | BF3D88FB1ECDC6B600E1AC1B /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
65 | BF3D88FE1ECDC6B600E1AC1B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
66 | BF3D89001ECDC6B600E1AC1B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
67 | BF3D89031ECDC6B600E1AC1B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
68 | BF3D89051ECDC6B600E1AC1B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
69 | /* End PBXFileReference section */
70 |
71 | /* Begin PBXFrameworksBuildPhase section */
72 | BF3D88D31ECDB5DA00E1AC1B /* Frameworks */ = {
73 | isa = PBXFrameworksBuildPhase;
74 | buildActionMask = 2147483647;
75 | files = (
76 | );
77 | runOnlyForDeploymentPostprocessing = 0;
78 | };
79 | BF3D88DD1ECDB5DA00E1AC1B /* Frameworks */ = {
80 | isa = PBXFrameworksBuildPhase;
81 | buildActionMask = 2147483647;
82 | files = (
83 | BF3D88E11ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayout.framework in Frameworks */,
84 | );
85 | runOnlyForDeploymentPostprocessing = 0;
86 | };
87 | BF3D88F41ECDC6B600E1AC1B /* Frameworks */ = {
88 | isa = PBXFrameworksBuildPhase;
89 | buildActionMask = 2147483647;
90 | files = (
91 | BF3D890C1ECDC71800E1AC1B /* CollectionViewMultiColumnLayout.framework in Frameworks */,
92 | );
93 | runOnlyForDeploymentPostprocessing = 0;
94 | };
95 | /* End PBXFrameworksBuildPhase section */
96 |
97 | /* Begin PBXGroup section */
98 | BF3D88CD1ECDB5DA00E1AC1B = {
99 | isa = PBXGroup;
100 | children = (
101 | BF3D88D91ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayout */,
102 | BF3D88E41ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayoutTests */,
103 | BF3D88F81ECDC6B600E1AC1B /* CollectionViewMultiColumnLayoutDemo */,
104 | BF3D88D81ECDB5DA00E1AC1B /* Products */,
105 | );
106 | sourceTree = "";
107 | };
108 | BF3D88D81ECDB5DA00E1AC1B /* Products */ = {
109 | isa = PBXGroup;
110 | children = (
111 | BF3D88D71ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayout.framework */,
112 | BF3D88E01ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayoutTests.xctest */,
113 | BF3D88F71ECDC6B600E1AC1B /* CollectionViewMultiColumnLayoutDemo.app */,
114 | );
115 | name = Products;
116 | sourceTree = "";
117 | };
118 | BF3D88D91ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayout */ = {
119 | isa = PBXGroup;
120 | children = (
121 | BF3D88DA1ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayout.h */,
122 | BF3D88F11ECDB5F600E1AC1B /* CollectionViewMultiColumnLayout.swift */,
123 | BF3D88DB1ECDB5DA00E1AC1B /* Info.plist */,
124 | );
125 | path = CollectionViewMultiColumnLayout;
126 | sourceTree = "";
127 | };
128 | BF3D88E41ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayoutTests */ = {
129 | isa = PBXGroup;
130 | children = (
131 | BF3D88E51ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayoutTests.swift */,
132 | BF3D88E71ECDB5DA00E1AC1B /* Info.plist */,
133 | );
134 | path = CollectionViewMultiColumnLayoutTests;
135 | sourceTree = "";
136 | };
137 | BF3D88F81ECDC6B600E1AC1B /* CollectionViewMultiColumnLayoutDemo */ = {
138 | isa = PBXGroup;
139 | children = (
140 | BF3D88F91ECDC6B600E1AC1B /* AppDelegate.swift */,
141 | BF3D88FB1ECDC6B600E1AC1B /* ViewController.swift */,
142 | BF3D88FD1ECDC6B600E1AC1B /* Main.storyboard */,
143 | BF3D89001ECDC6B600E1AC1B /* Assets.xcassets */,
144 | BF3D89021ECDC6B600E1AC1B /* LaunchScreen.storyboard */,
145 | BF3D89051ECDC6B600E1AC1B /* Info.plist */,
146 | );
147 | path = CollectionViewMultiColumnLayoutDemo;
148 | sourceTree = "";
149 | };
150 | /* End PBXGroup section */
151 |
152 | /* Begin PBXHeadersBuildPhase section */
153 | BF3D88D41ECDB5DA00E1AC1B /* Headers */ = {
154 | isa = PBXHeadersBuildPhase;
155 | buildActionMask = 2147483647;
156 | files = (
157 | BF3D88E81ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayout.h in Headers */,
158 | );
159 | runOnlyForDeploymentPostprocessing = 0;
160 | };
161 | /* End PBXHeadersBuildPhase section */
162 |
163 | /* Begin PBXNativeTarget section */
164 | BF3D88D61ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayout */ = {
165 | isa = PBXNativeTarget;
166 | buildConfigurationList = BF3D88EB1ECDB5DA00E1AC1B /* Build configuration list for PBXNativeTarget "CollectionViewMultiColumnLayout" */;
167 | buildPhases = (
168 | BF3D88D21ECDB5DA00E1AC1B /* Sources */,
169 | BF3D88D31ECDB5DA00E1AC1B /* Frameworks */,
170 | BF3D88D41ECDB5DA00E1AC1B /* Headers */,
171 | BF3D88D51ECDB5DA00E1AC1B /* Resources */,
172 | );
173 | buildRules = (
174 | );
175 | dependencies = (
176 | );
177 | name = CollectionViewMultiColumnLayout;
178 | productName = CollectionViewMultiColumnLayout;
179 | productReference = BF3D88D71ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayout.framework */;
180 | productType = "com.apple.product-type.framework";
181 | };
182 | BF3D88DF1ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayoutTests */ = {
183 | isa = PBXNativeTarget;
184 | buildConfigurationList = BF3D88EE1ECDB5DA00E1AC1B /* Build configuration list for PBXNativeTarget "CollectionViewMultiColumnLayoutTests" */;
185 | buildPhases = (
186 | BF3D88DC1ECDB5DA00E1AC1B /* Sources */,
187 | BF3D88DD1ECDB5DA00E1AC1B /* Frameworks */,
188 | BF3D88DE1ECDB5DA00E1AC1B /* Resources */,
189 | );
190 | buildRules = (
191 | );
192 | dependencies = (
193 | BF3D88E31ECDB5DA00E1AC1B /* PBXTargetDependency */,
194 | );
195 | name = CollectionViewMultiColumnLayoutTests;
196 | productName = CollectionViewMultiColumnLayoutTests;
197 | productReference = BF3D88E01ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayoutTests.xctest */;
198 | productType = "com.apple.product-type.bundle.unit-test";
199 | };
200 | BF3D88F61ECDC6B600E1AC1B /* CollectionViewMultiColumnLayoutDemo */ = {
201 | isa = PBXNativeTarget;
202 | buildConfigurationList = BF3D89061ECDC6B600E1AC1B /* Build configuration list for PBXNativeTarget "CollectionViewMultiColumnLayoutDemo" */;
203 | buildPhases = (
204 | BF3D88F31ECDC6B600E1AC1B /* Sources */,
205 | BF3D88F41ECDC6B600E1AC1B /* Frameworks */,
206 | BF3D88F51ECDC6B600E1AC1B /* Resources */,
207 | BF3D890E1ECDC71800E1AC1B /* Embed Frameworks */,
208 | );
209 | buildRules = (
210 | );
211 | dependencies = (
212 | BF3D890A1ECDC70700E1AC1B /* PBXTargetDependency */,
213 | );
214 | name = CollectionViewMultiColumnLayoutDemo;
215 | productName = CollectionViewMultiColumnLayoutDemo;
216 | productReference = BF3D88F71ECDC6B600E1AC1B /* CollectionViewMultiColumnLayoutDemo.app */;
217 | productType = "com.apple.product-type.application";
218 | };
219 | /* End PBXNativeTarget section */
220 |
221 | /* Begin PBXProject section */
222 | BF3D88CE1ECDB5DA00E1AC1B /* Project object */ = {
223 | isa = PBXProject;
224 | attributes = {
225 | LastSwiftUpdateCheck = 0830;
226 | LastUpgradeCheck = 0830;
227 | ORGANIZATIONNAME = "Vincent Esche";
228 | TargetAttributes = {
229 | BF3D88D61ECDB5DA00E1AC1B = {
230 | CreatedOnToolsVersion = 8.3.2;
231 | LastSwiftMigration = 0830;
232 | ProvisioningStyle = Manual;
233 | };
234 | BF3D88DF1ECDB5DA00E1AC1B = {
235 | CreatedOnToolsVersion = 8.3.2;
236 | ProvisioningStyle = Manual;
237 | };
238 | BF3D88F61ECDC6B600E1AC1B = {
239 | CreatedOnToolsVersion = 8.3.2;
240 | ProvisioningStyle = Manual;
241 | };
242 | };
243 | };
244 | buildConfigurationList = BF3D88D11ECDB5DA00E1AC1B /* Build configuration list for PBXProject "CollectionViewMultiColumnLayout" */;
245 | compatibilityVersion = "Xcode 3.2";
246 | developmentRegion = English;
247 | hasScannedForEncodings = 0;
248 | knownRegions = (
249 | en,
250 | Base,
251 | );
252 | mainGroup = BF3D88CD1ECDB5DA00E1AC1B;
253 | productRefGroup = BF3D88D81ECDB5DA00E1AC1B /* Products */;
254 | projectDirPath = "";
255 | projectRoot = "";
256 | targets = (
257 | BF3D88D61ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayout */,
258 | BF3D88DF1ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayoutTests */,
259 | BF3D88F61ECDC6B600E1AC1B /* CollectionViewMultiColumnLayoutDemo */,
260 | );
261 | };
262 | /* End PBXProject section */
263 |
264 | /* Begin PBXResourcesBuildPhase section */
265 | BF3D88D51ECDB5DA00E1AC1B /* Resources */ = {
266 | isa = PBXResourcesBuildPhase;
267 | buildActionMask = 2147483647;
268 | files = (
269 | );
270 | runOnlyForDeploymentPostprocessing = 0;
271 | };
272 | BF3D88DE1ECDB5DA00E1AC1B /* Resources */ = {
273 | isa = PBXResourcesBuildPhase;
274 | buildActionMask = 2147483647;
275 | files = (
276 | );
277 | runOnlyForDeploymentPostprocessing = 0;
278 | };
279 | BF3D88F51ECDC6B600E1AC1B /* Resources */ = {
280 | isa = PBXResourcesBuildPhase;
281 | buildActionMask = 2147483647;
282 | files = (
283 | BF3D89041ECDC6B600E1AC1B /* LaunchScreen.storyboard in Resources */,
284 | BF3D89011ECDC6B600E1AC1B /* Assets.xcassets in Resources */,
285 | BF3D88FF1ECDC6B600E1AC1B /* Main.storyboard in Resources */,
286 | );
287 | runOnlyForDeploymentPostprocessing = 0;
288 | };
289 | /* End PBXResourcesBuildPhase section */
290 |
291 | /* Begin PBXSourcesBuildPhase section */
292 | BF3D88D21ECDB5DA00E1AC1B /* Sources */ = {
293 | isa = PBXSourcesBuildPhase;
294 | buildActionMask = 2147483647;
295 | files = (
296 | BF3D88F21ECDB5F600E1AC1B /* CollectionViewMultiColumnLayout.swift in Sources */,
297 | );
298 | runOnlyForDeploymentPostprocessing = 0;
299 | };
300 | BF3D88DC1ECDB5DA00E1AC1B /* Sources */ = {
301 | isa = PBXSourcesBuildPhase;
302 | buildActionMask = 2147483647;
303 | files = (
304 | BF3D88E61ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayoutTests.swift in Sources */,
305 | );
306 | runOnlyForDeploymentPostprocessing = 0;
307 | };
308 | BF3D88F31ECDC6B600E1AC1B /* Sources */ = {
309 | isa = PBXSourcesBuildPhase;
310 | buildActionMask = 2147483647;
311 | files = (
312 | BF3D88FC1ECDC6B600E1AC1B /* ViewController.swift in Sources */,
313 | BF3D88FA1ECDC6B600E1AC1B /* AppDelegate.swift in Sources */,
314 | );
315 | runOnlyForDeploymentPostprocessing = 0;
316 | };
317 | /* End PBXSourcesBuildPhase section */
318 |
319 | /* Begin PBXTargetDependency section */
320 | BF3D88E31ECDB5DA00E1AC1B /* PBXTargetDependency */ = {
321 | isa = PBXTargetDependency;
322 | target = BF3D88D61ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayout */;
323 | targetProxy = BF3D88E21ECDB5DA00E1AC1B /* PBXContainerItemProxy */;
324 | };
325 | BF3D890A1ECDC70700E1AC1B /* PBXTargetDependency */ = {
326 | isa = PBXTargetDependency;
327 | target = BF3D88D61ECDB5DA00E1AC1B /* CollectionViewMultiColumnLayout */;
328 | targetProxy = BF3D89091ECDC70700E1AC1B /* PBXContainerItemProxy */;
329 | };
330 | /* End PBXTargetDependency section */
331 |
332 | /* Begin PBXVariantGroup section */
333 | BF3D88FD1ECDC6B600E1AC1B /* Main.storyboard */ = {
334 | isa = PBXVariantGroup;
335 | children = (
336 | BF3D88FE1ECDC6B600E1AC1B /* Base */,
337 | );
338 | name = Main.storyboard;
339 | sourceTree = "";
340 | };
341 | BF3D89021ECDC6B600E1AC1B /* LaunchScreen.storyboard */ = {
342 | isa = PBXVariantGroup;
343 | children = (
344 | BF3D89031ECDC6B600E1AC1B /* Base */,
345 | );
346 | name = LaunchScreen.storyboard;
347 | sourceTree = "";
348 | };
349 | /* End PBXVariantGroup section */
350 |
351 | /* Begin XCBuildConfiguration section */
352 | BF3D88E91ECDB5DA00E1AC1B /* Debug */ = {
353 | isa = XCBuildConfiguration;
354 | buildSettings = {
355 | ALWAYS_SEARCH_USER_PATHS = NO;
356 | CLANG_ANALYZER_NONNULL = YES;
357 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
358 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
359 | CLANG_CXX_LIBRARY = "libc++";
360 | CLANG_ENABLE_MODULES = YES;
361 | CLANG_ENABLE_OBJC_ARC = YES;
362 | CLANG_WARN_BOOL_CONVERSION = YES;
363 | CLANG_WARN_CONSTANT_CONVERSION = YES;
364 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
365 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
366 | CLANG_WARN_EMPTY_BODY = YES;
367 | CLANG_WARN_ENUM_CONVERSION = YES;
368 | CLANG_WARN_INFINITE_RECURSION = YES;
369 | CLANG_WARN_INT_CONVERSION = YES;
370 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
371 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
372 | CLANG_WARN_UNREACHABLE_CODE = YES;
373 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
374 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
375 | COPY_PHASE_STRIP = NO;
376 | CURRENT_PROJECT_VERSION = 1;
377 | DEBUG_INFORMATION_FORMAT = dwarf;
378 | ENABLE_STRICT_OBJC_MSGSEND = YES;
379 | ENABLE_TESTABILITY = YES;
380 | GCC_C_LANGUAGE_STANDARD = gnu99;
381 | GCC_DYNAMIC_NO_PIC = NO;
382 | GCC_NO_COMMON_BLOCKS = YES;
383 | GCC_OPTIMIZATION_LEVEL = 0;
384 | GCC_PREPROCESSOR_DEFINITIONS = (
385 | "DEBUG=1",
386 | "$(inherited)",
387 | );
388 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
389 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
390 | GCC_WARN_UNDECLARED_SELECTOR = YES;
391 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
392 | GCC_WARN_UNUSED_FUNCTION = YES;
393 | GCC_WARN_UNUSED_VARIABLE = YES;
394 | IPHONEOS_DEPLOYMENT_TARGET = 10.3;
395 | MTL_ENABLE_DEBUG_INFO = YES;
396 | ONLY_ACTIVE_ARCH = YES;
397 | SDKROOT = iphoneos;
398 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
399 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
400 | TARGETED_DEVICE_FAMILY = "1,2";
401 | VERSIONING_SYSTEM = "apple-generic";
402 | VERSION_INFO_PREFIX = "";
403 | };
404 | name = Debug;
405 | };
406 | BF3D88EA1ECDB5DA00E1AC1B /* Release */ = {
407 | isa = XCBuildConfiguration;
408 | buildSettings = {
409 | ALWAYS_SEARCH_USER_PATHS = NO;
410 | CLANG_ANALYZER_NONNULL = YES;
411 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
412 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
413 | CLANG_CXX_LIBRARY = "libc++";
414 | CLANG_ENABLE_MODULES = YES;
415 | CLANG_ENABLE_OBJC_ARC = YES;
416 | CLANG_WARN_BOOL_CONVERSION = YES;
417 | CLANG_WARN_CONSTANT_CONVERSION = YES;
418 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
419 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
420 | CLANG_WARN_EMPTY_BODY = YES;
421 | CLANG_WARN_ENUM_CONVERSION = YES;
422 | CLANG_WARN_INFINITE_RECURSION = YES;
423 | CLANG_WARN_INT_CONVERSION = YES;
424 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
425 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
426 | CLANG_WARN_UNREACHABLE_CODE = YES;
427 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
428 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
429 | COPY_PHASE_STRIP = NO;
430 | CURRENT_PROJECT_VERSION = 1;
431 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
432 | ENABLE_NS_ASSERTIONS = NO;
433 | ENABLE_STRICT_OBJC_MSGSEND = YES;
434 | GCC_C_LANGUAGE_STANDARD = gnu99;
435 | GCC_NO_COMMON_BLOCKS = YES;
436 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
437 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
438 | GCC_WARN_UNDECLARED_SELECTOR = YES;
439 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
440 | GCC_WARN_UNUSED_FUNCTION = YES;
441 | GCC_WARN_UNUSED_VARIABLE = YES;
442 | IPHONEOS_DEPLOYMENT_TARGET = 10.3;
443 | MTL_ENABLE_DEBUG_INFO = NO;
444 | SDKROOT = iphoneos;
445 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
446 | TARGETED_DEVICE_FAMILY = "1,2";
447 | VALIDATE_PRODUCT = YES;
448 | VERSIONING_SYSTEM = "apple-generic";
449 | VERSION_INFO_PREFIX = "";
450 | };
451 | name = Release;
452 | };
453 | BF3D88EC1ECDB5DA00E1AC1B /* Debug */ = {
454 | isa = XCBuildConfiguration;
455 | buildSettings = {
456 | CLANG_ENABLE_MODULES = YES;
457 | CODE_SIGN_IDENTITY = "";
458 | DEFINES_MODULE = YES;
459 | DEVELOPMENT_TEAM = "";
460 | DYLIB_COMPATIBILITY_VERSION = 1;
461 | DYLIB_CURRENT_VERSION = 1;
462 | DYLIB_INSTALL_NAME_BASE = "@rpath";
463 | INFOPLIST_FILE = CollectionViewMultiColumnLayout/Info.plist;
464 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
465 | IPHONEOS_DEPLOYMENT_TARGET = 8.4;
466 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
467 | PRODUCT_BUNDLE_IDENTIFIER = com.regexident.CollectionViewMultiColumnLayout;
468 | PRODUCT_NAME = "$(TARGET_NAME)";
469 | PROVISIONING_PROFILE_SPECIFIER = "";
470 | SKIP_INSTALL = YES;
471 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
472 | SWIFT_VERSION = 3.0;
473 | };
474 | name = Debug;
475 | };
476 | BF3D88ED1ECDB5DA00E1AC1B /* Release */ = {
477 | isa = XCBuildConfiguration;
478 | buildSettings = {
479 | CLANG_ENABLE_MODULES = YES;
480 | CODE_SIGN_IDENTITY = "";
481 | DEFINES_MODULE = YES;
482 | DEVELOPMENT_TEAM = "";
483 | DYLIB_COMPATIBILITY_VERSION = 1;
484 | DYLIB_CURRENT_VERSION = 1;
485 | DYLIB_INSTALL_NAME_BASE = "@rpath";
486 | INFOPLIST_FILE = CollectionViewMultiColumnLayout/Info.plist;
487 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
488 | IPHONEOS_DEPLOYMENT_TARGET = 8.4;
489 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
490 | PRODUCT_BUNDLE_IDENTIFIER = com.regexident.CollectionViewMultiColumnLayout;
491 | PRODUCT_NAME = "$(TARGET_NAME)";
492 | PROVISIONING_PROFILE_SPECIFIER = "";
493 | SKIP_INSTALL = YES;
494 | SWIFT_VERSION = 3.0;
495 | };
496 | name = Release;
497 | };
498 | BF3D88EF1ECDB5DA00E1AC1B /* Debug */ = {
499 | isa = XCBuildConfiguration;
500 | buildSettings = {
501 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
502 | DEVELOPMENT_TEAM = "";
503 | INFOPLIST_FILE = CollectionViewMultiColumnLayoutTests/Info.plist;
504 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
505 | PRODUCT_BUNDLE_IDENTIFIER = com.regexident.CollectionViewMultiColumnLayoutTests;
506 | PRODUCT_NAME = "$(TARGET_NAME)";
507 | PROVISIONING_PROFILE_SPECIFIER = "";
508 | SWIFT_VERSION = 3.0;
509 | };
510 | name = Debug;
511 | };
512 | BF3D88F01ECDB5DA00E1AC1B /* Release */ = {
513 | isa = XCBuildConfiguration;
514 | buildSettings = {
515 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
516 | DEVELOPMENT_TEAM = "";
517 | INFOPLIST_FILE = CollectionViewMultiColumnLayoutTests/Info.plist;
518 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
519 | PRODUCT_BUNDLE_IDENTIFIER = com.regexident.CollectionViewMultiColumnLayoutTests;
520 | PRODUCT_NAME = "$(TARGET_NAME)";
521 | PROVISIONING_PROFILE_SPECIFIER = "";
522 | SWIFT_VERSION = 3.0;
523 | };
524 | name = Release;
525 | };
526 | BF3D89071ECDC6B600E1AC1B /* Debug */ = {
527 | isa = XCBuildConfiguration;
528 | buildSettings = {
529 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
530 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
531 | DEVELOPMENT_TEAM = "";
532 | INFOPLIST_FILE = CollectionViewMultiColumnLayoutDemo/Info.plist;
533 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
534 | PRODUCT_BUNDLE_IDENTIFIER = com.regexident.CollectionViewMultiColumnLayoutDemo;
535 | PRODUCT_NAME = "$(TARGET_NAME)";
536 | PROVISIONING_PROFILE_SPECIFIER = "";
537 | SWIFT_VERSION = 3.0;
538 | };
539 | name = Debug;
540 | };
541 | BF3D89081ECDC6B600E1AC1B /* Release */ = {
542 | isa = XCBuildConfiguration;
543 | buildSettings = {
544 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
545 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
546 | DEVELOPMENT_TEAM = "";
547 | INFOPLIST_FILE = CollectionViewMultiColumnLayoutDemo/Info.plist;
548 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
549 | PRODUCT_BUNDLE_IDENTIFIER = com.regexident.CollectionViewMultiColumnLayoutDemo;
550 | PRODUCT_NAME = "$(TARGET_NAME)";
551 | PROVISIONING_PROFILE_SPECIFIER = "";
552 | SWIFT_VERSION = 3.0;
553 | };
554 | name = Release;
555 | };
556 | /* End XCBuildConfiguration section */
557 |
558 | /* Begin XCConfigurationList section */
559 | BF3D88D11ECDB5DA00E1AC1B /* Build configuration list for PBXProject "CollectionViewMultiColumnLayout" */ = {
560 | isa = XCConfigurationList;
561 | buildConfigurations = (
562 | BF3D88E91ECDB5DA00E1AC1B /* Debug */,
563 | BF3D88EA1ECDB5DA00E1AC1B /* Release */,
564 | );
565 | defaultConfigurationIsVisible = 0;
566 | defaultConfigurationName = Release;
567 | };
568 | BF3D88EB1ECDB5DA00E1AC1B /* Build configuration list for PBXNativeTarget "CollectionViewMultiColumnLayout" */ = {
569 | isa = XCConfigurationList;
570 | buildConfigurations = (
571 | BF3D88EC1ECDB5DA00E1AC1B /* Debug */,
572 | BF3D88ED1ECDB5DA00E1AC1B /* Release */,
573 | );
574 | defaultConfigurationIsVisible = 0;
575 | defaultConfigurationName = Release;
576 | };
577 | BF3D88EE1ECDB5DA00E1AC1B /* Build configuration list for PBXNativeTarget "CollectionViewMultiColumnLayoutTests" */ = {
578 | isa = XCConfigurationList;
579 | buildConfigurations = (
580 | BF3D88EF1ECDB5DA00E1AC1B /* Debug */,
581 | BF3D88F01ECDB5DA00E1AC1B /* Release */,
582 | );
583 | defaultConfigurationIsVisible = 0;
584 | defaultConfigurationName = Release;
585 | };
586 | BF3D89061ECDC6B600E1AC1B /* Build configuration list for PBXNativeTarget "CollectionViewMultiColumnLayoutDemo" */ = {
587 | isa = XCConfigurationList;
588 | buildConfigurations = (
589 | BF3D89071ECDC6B600E1AC1B /* Debug */,
590 | BF3D89081ECDC6B600E1AC1B /* Release */,
591 | );
592 | defaultConfigurationIsVisible = 0;
593 | defaultConfigurationName = Release;
594 | };
595 | /* End XCConfigurationList section */
596 | };
597 | rootObject = BF3D88CE1ECDB5DA00E1AC1B /* Project object */;
598 | }
599 |
--------------------------------------------------------------------------------