├── .github └── FUNDING.yml ├── .gitignore ├── .swift-version ├── Demo ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── ColorCell.swift ├── DataSource.swift ├── HeaderView.swift ├── HeaderView.xib ├── Info.plist ├── TextCell.swift ├── TextCell.xib ├── ViewController.swift └── test_data.json ├── LICENSE ├── README.md ├── Sources └── WaterfallLayout.swift ├── WaterfallLayout.podspec ├── WaterfallLayout.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ ├── Demo.xcscheme │ └── WaterfallLayout.xcscheme ├── WaterfallLayout.xcworkspace └── contents.xcworkspacedata ├── WaterfallLayout ├── Info.plist └── WaterfallLayout.h ├── demo.gif └── logo.png /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: sgr-ksmt 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | ## Playgrounds 32 | timeline.xctimeline 33 | playground.xcworkspace 34 | 35 | # Swift Package Manager 36 | # 37 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 38 | # Packages/ 39 | # Package.pins 40 | .build/ 41 | 42 | # CocoaPods 43 | # 44 | # We recommend against adding the Pods directory to your .gitignore. However 45 | # you should judge for yourself, the pros and cons are mentioned at: 46 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 47 | # 48 | # Pods/ 49 | 50 | # Carthage 51 | # 52 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 53 | # Carthage/Checkouts 54 | 55 | Carthage/Build 56 | 57 | # fastlane 58 | # 59 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 60 | # screenshots whenever they are needed. 61 | # For more information about the recommended setup visit: 62 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 63 | 64 | fastlane/report.xml 65 | fastlane/Preview.html 66 | fastlane/screenshots 67 | fastlane/test_output 68 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 4.2 2 | -------------------------------------------------------------------------------- /Demo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Demo 4 | // 5 | // Created by suguru-kishimoto on 2017/10/03. 6 | // Copyright © 2017年 Suguru Kishimoto. 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: [UIApplication.LaunchOptionsKey: 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 | -------------------------------------------------------------------------------- /Demo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /Demo/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 | -------------------------------------------------------------------------------- /Demo/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 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /Demo/ColorCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColorCell.swift 3 | // Demo 4 | // 5 | // Created by suguru-kishimoto on 2017/10/04. 6 | // Copyright © 2017年 Suguru Kishimoto. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | final class ColorCell: UICollectionViewCell { 12 | func configure(with color: UIColor) { 13 | backgroundColor = color 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Demo/DataSource.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DataSource.swift 3 | // Demo 4 | // 5 | // Created by suguru-kishimoto on 2017/10/03. 6 | // Copyright © 2017年 Suguru Kishimoto. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | struct SampleResponse: Decodable { 12 | struct Item: Decodable { 13 | var color: UIColor 14 | var size: CGSize 15 | 16 | enum CodingKeys: String, CodingKey { 17 | case color 18 | case size 19 | } 20 | init(from decoder: Decoder) throws { 21 | let container = try decoder.container(keyedBy: CodingKeys.self) 22 | self.size = try container.decode(CGSize.self, forKey: .size) 23 | let hex = try container.decode(String.self, forKey: .color) 24 | guard let color = UIColor(hex: hex) else { 25 | throw NSError(domain: "", code: 0, userInfo: nil) 26 | } 27 | self.color = color 28 | } 29 | } 30 | 31 | struct News: Decodable { 32 | var title: String 33 | var description: String 34 | } 35 | 36 | enum Content: String, Decodable { 37 | case topicItem = "topic_item" 38 | case items 39 | case news 40 | } 41 | 42 | enum CodingKeys: String, CodingKey { 43 | case topicItem = "topic_item" 44 | case items 45 | case news 46 | case contents 47 | } 48 | 49 | var topicItem: Item 50 | var items: [Item] 51 | var news: [News] 52 | var contents: [Content] 53 | 54 | init(from decoder: Decoder) throws { 55 | let container = try decoder.container(keyedBy: CodingKeys.self) 56 | self.topicItem = try container.decode(Item.self, forKey: .topicItem) 57 | self.items = try container.decode([Item].self, forKey: .items) 58 | self.news = try container.decode([News].self, forKey: .news) 59 | self.contents = try container.decode([Content].self, forKey: .contents) 60 | } 61 | } 62 | 63 | extension UIColor { 64 | convenience init?(hex: String) { 65 | var hexCode: String = hex.trimmingCharacters(in: .whitespacesAndNewlines).uppercased() 66 | 67 | if (hexCode.hasPrefix("#")) { 68 | hexCode.remove(at: hexCode.startIndex) 69 | } 70 | 71 | if(hexCode.count != 6) { 72 | return nil 73 | } 74 | 75 | var rgbValue: UInt32 = 0 76 | Scanner(string: hexCode).scanHexInt32(&rgbValue) 77 | 78 | self.init(red: CGFloat((rgbValue & 0xFF0000) >> 16) / 255.0, 79 | green: CGFloat((rgbValue & 0x00FF00) >> 8) / 255.0, 80 | blue: CGFloat(rgbValue & 0x0000FF) / 255.0, 81 | alpha: CGFloat(1.0)) 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Demo/HeaderView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HeaderView.swift 3 | // Demo 4 | // 5 | // Created by suguru-kishimoto on 2017/10/04. 6 | // Copyright © 2017年 Suguru Kishimoto. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | final class HeaderView: UICollectionReusableView { 12 | @IBOutlet private weak var titleLabel: UILabel! 13 | 14 | func configure(with title: String) { 15 | titleLabel.text = title 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Demo/HeaderView.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Demo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | -------------------------------------------------------------------------------- /Demo/TextCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TextCell.swift 3 | // Demo 4 | // 5 | // Created by suguru-kishimoto on 2017/10/04. 6 | // Copyright © 2017年 Suguru Kishimoto. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | final class TextCell: UICollectionViewCell { 12 | @IBOutlet private weak var titleLabel: UILabel! 13 | @IBOutlet private weak var descriptionLabel: UILabel! 14 | 15 | override func awakeFromNib() { 16 | super.awakeFromNib() 17 | } 18 | func configure(with news: (title: String, description: String)) { 19 | titleLabel.text = news.title 20 | descriptionLabel.text = news.description 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Demo/TextCell.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /Demo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Demo 4 | // 5 | // Created by suguru-kishimoto on 2017/10/03. 6 | // Copyright © 2017年 Suguru Kishimoto. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import WaterfallLayout 11 | 12 | class ViewController: UIViewController { 13 | 14 | @IBOutlet private weak var collectionView: UICollectionView! { 15 | didSet { 16 | let layout = WaterfallLayout() 17 | layout.delegate = self 18 | layout.sectionInset = UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16) 19 | layout.minimumLineSpacing = 8.0 20 | layout.minimumInteritemSpacing = 8.0 21 | layout.headerHeight = 50.0 22 | collectionView.collectionViewLayout = layout 23 | collectionView.register(UINib(nibName: "TextCell", bundle: nil), forCellWithReuseIdentifier: "TextCell") 24 | collectionView.register(ColorCell.self, forCellWithReuseIdentifier: "ColorCell") 25 | collectionView.register(UINib(nibName: "HeaderView", bundle: nil), forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "HeaderView") 26 | collectionView.dataSource = self 27 | } 28 | } 29 | 30 | private lazy var response: SampleResponse = { 31 | let jsonURL = Bundle.main.url(forResource: "test_data", withExtension: "json")! 32 | let jsonData = try! Data(contentsOf: jsonURL) 33 | return try! JSONDecoder().decode(SampleResponse.self, from: jsonData) 34 | }() 35 | 36 | override func viewDidLoad() { 37 | super.viewDidLoad() 38 | title = "Example" 39 | } 40 | } 41 | 42 | extension ViewController: UICollectionViewDataSource { 43 | func numberOfSections(in collectionView: UICollectionView) -> Int { 44 | return response.contents.count 45 | } 46 | 47 | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 48 | switch response.contents[section] { 49 | case .topicItem: 50 | return 1 51 | case .items: 52 | return response.items.count 53 | case .news: 54 | return response.news.count 55 | } 56 | } 57 | 58 | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 59 | switch response.contents[indexPath.section] { 60 | case .topicItem: 61 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ColorCell", for: indexPath) as! ColorCell 62 | cell.configure(with: response.topicItem.color) 63 | return cell 64 | case .items: 65 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ColorCell", for: indexPath) as! ColorCell 66 | cell.configure(with: response.items[indexPath.item].color) 67 | return cell 68 | case .news: 69 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "TextCell", for: indexPath) as! TextCell 70 | cell.backgroundColor = .lightGray 71 | let news = response.news[indexPath.item] 72 | cell.configure(with: (news.title, news.description)) 73 | return cell 74 | } 75 | } 76 | 77 | func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView { 78 | switch kind { 79 | case UICollectionView.elementKindSectionHeader: 80 | let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "HeaderView", for: indexPath) as! HeaderView 81 | switch response.contents[indexPath.section] { 82 | case .topicItem: header.configure(with: "Topic color using flow layout") 83 | case .items: header.configure(with: "Colors using waterfall layout") 84 | case .news: header.configure(with: "texts using auto layout") 85 | } 86 | return header 87 | default: 88 | return UICollectionReusableView() 89 | } 90 | } 91 | } 92 | 93 | extension ViewController: WaterfallLayoutDelegate { 94 | func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { 95 | switch response.contents[indexPath.section] { 96 | case .topicItem: 97 | return response.topicItem.size 98 | case .items: 99 | return response.items[indexPath.item].size 100 | case .news: 101 | return WaterfallLayout.automaticSize //CGSize(width: 300, height: 180) 102 | } 103 | } 104 | 105 | func collectionViewLayout(for section: Int) -> WaterfallLayout.Layout { 106 | switch response.contents[section] { 107 | case .topicItem: return .flow(column: 1) 108 | case .items: return .waterfall(column: 2, distributionMethod: .balanced) 109 | case .news: return .flow(column: 1) 110 | } 111 | } 112 | 113 | } 114 | -------------------------------------------------------------------------------- /Demo/test_data.json: -------------------------------------------------------------------------------- 1 | { 2 | "topic_item": { 3 | "color": "#123456", 4 | "size": [300, 300] 5 | }, 6 | "items": [ 7 | { 8 | "color": "#FF4567", 9 | "size": [300, 200] 10 | }, 11 | { 12 | "color": "#34FF78", 13 | "size": [300, 300] 14 | }, 15 | { 16 | "color": "#4567FF", 17 | "size": [300, 400] 18 | }, 19 | { 20 | "color": "#FF789A", 21 | "size": [300, 350] 22 | }, 23 | { 24 | "color": "#67FFAB", 25 | "size": [300, 200] 26 | }, 27 | { 28 | "color": "#FF4567", 29 | "size": [300, 200] 30 | }, 31 | { 32 | "color": "#34FF78", 33 | "size": [300, 300] 34 | }, 35 | { 36 | "color": "#4567FF", 37 | "size": [300, 400] 38 | }, 39 | { 40 | "color": "#FF789A", 41 | "size": [300, 350] 42 | }, 43 | { 44 | "color": "#67FFAB", 45 | "size": [300, 200] 46 | } 47 | ], 48 | "news": [ 49 | { 50 | "title": "foo", 51 | "description": "foobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbaz" 52 | }, 53 | { 54 | "title": "foo", 55 | "description": "foobarbazfoobarbazfoobarbazfoobarbazfoobarbaz" 56 | }, 57 | { 58 | "title": "foo", 59 | "description": "foobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbaz" 60 | }, 61 | { 62 | "title": "foo", 63 | "description": "foobarbazfoobarbazfoobarbazfoobarbazfoobarbaz" 64 | }, 65 | { 66 | "title": "foo", 67 | "description": "foobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbaz" 68 | }, 69 | { 70 | "title": "foo", 71 | "description": "foobarbazfoobarbazfoobarbazfoobarbazfoobarbaz" 72 | }, 73 | { 74 | "title": "foo", 75 | "description": "foobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbazfoobarbaz" 76 | }, 77 | { 78 | "title": "foo", 79 | "description": "foobarbazfoobarbazfoobarbazfoobarbazfoobarbaz" 80 | } 81 | ], 82 | "contents": [ 83 | "topic_item", 84 | "items", 85 | "news" 86 | ] 87 | } 88 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Suguru Kishimoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WaterfallLayout 2 | Waterfall layout in iOS 3 | 4 | [![GitHub release](https://img.shields.io/github/release/sgr-ksmt/WaterfallLayout.svg)](https://github.com/sgr-ksmt/WaterfallLayout/releases) 5 | ![Language](https://img.shields.io/badge/language-Swift%204.2-orange.svg) 6 | [![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 7 | [![CocoaPods](https://img.shields.io/badge/Cocoa%20Pods-✓-4BC51D.svg?style=flat)](https://cocoapods.org/pods/WaterfallLayout) 8 | [![CocoaPodsDL](https://img.shields.io/cocoapods/dt/WaterfallLayout.svg)](https://cocoapods.org/pods/WaterfallLayout) 9 | 10 | ![](logo.png) 11 | 12 | 13 | ## Features 14 | - Can select flow/waterfall layout per section. 15 | - Self-Sizing cell available 16 | 17 | 18 | ![](demo.gif) 19 | 20 | ## How to use 21 | 22 | ```swift 23 | class ViewController: UIViewController { 24 | 25 | @IBOutlet private weak var collectionView: UICollectionView! { 26 | didSet { 27 | let layout = WaterfallLayout() 28 | layout.delegate = self 29 | layout.sectionInset = UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16) 30 | layout.minimumLineSpacing = 8.0 31 | layout.minimumInteritemSpacing = 8.0 32 | layout.headerHeight = 50.0 33 | collectionView.collectionViewLayout = layout 34 | collectionView.register(...) 35 | collectionView.dataSource = self 36 | collectionView.delegate = self 37 | } 38 | } 39 | } 40 | 41 | extension ViewController: UICollectionDataSource { 42 | ... 43 | } 44 | 45 | extension ViewController: WaterfallLayoutDelegate { 46 | func collectionViewLayout(for section: Int) -> WaterfallLayout.Layout { 47 | switch section { 48 | case 0: return .flow(column: 1) // single column flow layout 49 | case 1: return .waterfall(column: 3) // three waterfall layout 50 | default: return .flow(column: 2) 51 | } 52 | } 53 | 54 | func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { 55 | return CGSize(...) 56 | } 57 | } 58 | ``` 59 | 60 | ### Properties 61 | ```swift 62 | public var minimumLineSpacing: CGFloat { get set } 63 | 64 | public var minimumInteritemSpacing: CGFloat { get set } 65 | 66 | public var sectionInset: UIEdgeInsets { get set } 67 | 68 | public var headerHeight: CGFloat { get set } 69 | 70 | public var headerInset: UIEdgeInsets { get set } 71 | 72 | public var footerHeight: CGFloat { get set } 73 | 74 | public var footerInset: UIEdgeInsets { get set } 75 | 76 | public var estimatedItemSize: CGSize { get set } 77 | ``` 78 | 79 | ### Layout delegte 80 | 81 | ```swift 82 | public protocol WaterfallLayoutDelegate: class { 83 | // MARK: - Required 84 | func collectionViewLayout(for section: Int) -> WaterfallLayout.Layout 85 | func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, sizeForItemAt indexPath: IndexPath) -> CGSize 86 | 87 | // MARK: - Optional 88 | func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, minimumInteritemSpacingFor section: Int) -> CGFloat? 89 | func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, minimumLineSpacingFor section: Int) -> CGFloat? 90 | func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, sectionInsetFor section: Int) -> UIEdgeInsets? 91 | func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, headerHeightFor section: Int) -> CGFloat? 92 | func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, headerInsetFor section: Int) -> UIEdgeInsets? 93 | func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, footerHeightFor section: Int) -> CGFloat? 94 | func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, footerInsetFor section: Int) -> UIEdgeInsets? 95 | func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, estimatedSizeForItemAt indexPath: IndexPath) -> CGSize? 96 | } 97 | ``` 98 | 99 | ## Requirements 100 | - iOS 9.0+ 101 | - Xcode 9+ 102 | - Swift 4+ 103 | 104 | ## Installation 105 | 106 | ### Carthage 107 | 108 | - Add the following to your *Cartfile*: 109 | 110 | ```bash 111 | github "sgr-ksmt/WaterfallLayout" ~> 0.1 112 | ``` 113 | 114 | - Run `carthage update` 115 | - Add the framework as described. 116 |
Details: [Carthage Readme](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application) 117 | 118 | 119 | ### CocoaPods 120 | 121 | **WaterfallLayout** is available through [CocoaPods](http://cocoapods.org). To install 122 | it, simply add the following line to your Podfile: 123 | 124 | ```ruby 125 | pod 'WaterfallLayout', '~> 0.1' 126 | ``` 127 | 128 | and run `pod install` 129 | 130 | ### Manually Install 131 | Download all `*.swift` files and put your project. 132 | 133 | ## Change log 134 | Change log is [here](https://github.com/sgr-ksmt/WaterfallLayout/blob/master/CHANGELOG.md). 135 | 136 | ## Communication 137 | - If you found a bug, open an issue. 138 | - If you have a feature request, open an issue. 139 | - If you want to contribute, submit a pull request.:muscle: 140 | 141 | ## License 142 | 143 | **WaterfallLayout** is under MIT license. See the [LICENSE](LICENSE) file for more info. 144 | -------------------------------------------------------------------------------- /Sources/WaterfallLayout.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WaterfallLayout.swift 3 | // WaterfallLayout 4 | // 5 | // Created by suguru-kishimoto on 2017/10/03. 6 | // Copyright © 2017年 Suguru Kishimoto. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public protocol WaterfallLayoutDelegate: class { 12 | // MARK: - Required 13 | func collectionViewLayout(for section: Int) -> WaterfallLayout.Layout 14 | func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, sizeForItemAt indexPath: IndexPath) -> CGSize 15 | 16 | // MARK: - Optional 17 | func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, minimumInteritemSpacingFor section: Int) -> CGFloat? 18 | func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, minimumLineSpacingFor section: Int) -> CGFloat? 19 | func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, sectionInsetFor section: Int) -> UIEdgeInsets? 20 | func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, headerHeightFor section: Int) -> CGFloat? 21 | func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, headerInsetFor section: Int) -> UIEdgeInsets? 22 | func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, footerHeightFor section: Int) -> CGFloat? 23 | func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, footerInsetFor section: Int) -> UIEdgeInsets? 24 | func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, estimatedSizeForItemAt indexPath: IndexPath) -> CGSize? 25 | } 26 | 27 | extension WaterfallLayoutDelegate { 28 | public func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, minimumInteritemSpacingFor section: Int) -> CGFloat? { return nil } 29 | public func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, minimumLineSpacingFor section: Int) -> CGFloat? { return nil } 30 | public func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, sectionInsetFor section: Int) -> UIEdgeInsets? { return nil } 31 | public func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, headerHeightFor section: Int) -> CGFloat? { return nil } 32 | public func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, headerInsetFor section: Int) -> UIEdgeInsets? { return nil } 33 | public func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, footerHeightFor section: Int) -> CGFloat? { return nil } 34 | public func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, footerInsetFor section: Int) -> UIEdgeInsets? { return nil } 35 | public func collectionView(_ collectionView: UICollectionView, layout: WaterfallLayout, estimatedSizeForItemAt indexPath: IndexPath) -> CGSize? { return nil } 36 | } 37 | 38 | public class WaterfallLayout: UICollectionViewLayout { 39 | public static let automaticSize: CGSize = CGSize(width: CGFloat.greatestFiniteMagnitude, height: .greatestFiniteMagnitude) 40 | 41 | public enum DistributionMethod { 42 | 43 | case equal 44 | case balanced 45 | } 46 | 47 | public enum Layout { 48 | case flow(column: Int) 49 | case waterfall(column: Int, distributionMethod :DistributionMethod) 50 | 51 | var column: Int { 52 | switch self { 53 | case let .flow(column): return column 54 | case let .waterfall(column, _): return column 55 | } 56 | } 57 | } 58 | 59 | public struct Const { 60 | static let minimumLineSpacing: CGFloat = 10.0 61 | static let minimumInteritemSpacing: CGFloat = 10.0 62 | static let sectionInset: UIEdgeInsets = .zero 63 | static let headerHeight: CGFloat = 0.0 64 | static let headerInset: UIEdgeInsets = .zero 65 | static let footerHeight: CGFloat = 0.0 66 | static let footerInset: UIEdgeInsets = .zero 67 | static let estimatedItemSize: CGSize = CGSize(width: 300.0, height: 300.0) 68 | } 69 | 70 | public var minimumLineSpacing: CGFloat = Const.minimumLineSpacing { 71 | didSet { invalidateLayoutIfChanged(oldValue, minimumLineSpacing) } 72 | } 73 | 74 | public var minimumInteritemSpacing: CGFloat = Const.minimumInteritemSpacing { 75 | didSet { invalidateLayoutIfChanged(oldValue, minimumInteritemSpacing) } 76 | } 77 | 78 | public var sectionInset: UIEdgeInsets = Const.sectionInset { 79 | didSet { invalidateLayoutIfChanged(oldValue, sectionInset) } 80 | } 81 | 82 | public var headerHeight: CGFloat = Const.headerHeight { 83 | didSet { invalidateLayoutIfChanged(oldValue, headerHeight) } 84 | } 85 | 86 | public var headerInset: UIEdgeInsets = Const.headerInset { 87 | didSet { invalidateLayoutIfChanged(oldValue, headerInset) } 88 | } 89 | 90 | public var footerHeight: CGFloat = Const.footerHeight { 91 | didSet { invalidateLayoutIfChanged(oldValue, footerHeight) } 92 | } 93 | 94 | public var footerInset: UIEdgeInsets = Const.footerInset { 95 | didSet { invalidateLayoutIfChanged(oldValue, footerInset) } 96 | } 97 | 98 | public var estimatedItemSize: CGSize = Const.estimatedItemSize { 99 | didSet { invalidateLayoutIfChanged(oldValue, estimatedItemSize) } 100 | } 101 | 102 | private lazy var headersAttribute = [Int: UICollectionViewLayoutAttributes]() 103 | private lazy var footersAttribute = [Int: UICollectionViewLayoutAttributes]() 104 | private lazy var columnHeights = [[CGFloat]]() 105 | private lazy var allItemAttributes = [UICollectionViewLayoutAttributes]() 106 | private lazy var sectionItemAttributes = [[UICollectionViewLayoutAttributes]]() 107 | private lazy var cachedItemSizes = [IndexPath: CGSize]() 108 | 109 | public weak var delegate: WaterfallLayoutDelegate? 110 | 111 | public override func prepare() { 112 | super.prepare() 113 | cleaunup() 114 | 115 | guard let collectionView = collectionView else { return } 116 | guard let delegate = delegate else { return } 117 | 118 | let numberOfSections = collectionView.numberOfSections 119 | if numberOfSections == 0 { return } 120 | 121 | (0.. 0 else { 136 | return .zero 137 | } 138 | var contentSize = collectionView.bounds.size 139 | contentSize.height = columnHeights.last?.first ?? 0.0 140 | return contentSize 141 | } 142 | 143 | public override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? { 144 | if indexPath.section >= sectionItemAttributes.count { 145 | return nil 146 | } 147 | if indexPath.item >= sectionItemAttributes[indexPath.section].count { 148 | return nil 149 | } 150 | return sectionItemAttributes[indexPath.section][indexPath.item] 151 | } 152 | 153 | public override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { 154 | return allItemAttributes.filter { rect.intersects($0.frame) } 155 | } 156 | 157 | public override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool { 158 | return newBounds.width != (collectionView?.bounds ?? .zero).width 159 | } 160 | 161 | override public func shouldInvalidateLayout(forPreferredLayoutAttributes preferredAttributes: UICollectionViewLayoutAttributes, withOriginalAttributes originalAttributes: UICollectionViewLayoutAttributes) -> Bool { 162 | if let delegate = delegate { 163 | // For .waterfall mode, disabling shouldInvalidateLayout will prevent infinite loop to occur due to unstable constraints. 164 | // e.g. UIImageView causes AL constraints to be updated due to content hugging that causes infinite UI update. 165 | if case .waterfall = delegate.collectionViewLayout(for: originalAttributes.indexPath.section) { 166 | return false 167 | } 168 | } 169 | 170 | return cachedItemSizes[originalAttributes.indexPath] != preferredAttributes.size 171 | } 172 | 173 | override public func invalidationContext(forPreferredLayoutAttributes preferredAttributes: UICollectionViewLayoutAttributes, withOriginalAttributes originalAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutInvalidationContext { 174 | let context = super.invalidationContext(forPreferredLayoutAttributes: preferredAttributes, withOriginalAttributes: originalAttributes) 175 | 176 | guard let _ = collectionView else { return context } 177 | 178 | let oldContentSize = self.collectionViewContentSize 179 | cachedItemSizes[originalAttributes.indexPath] = preferredAttributes.size 180 | let newContentSize = self.collectionViewContentSize 181 | context.contentSizeAdjustment = CGSize(width: 0, height: newContentSize.height - oldContentSize.height) 182 | 183 | /* 184 | let indexPaths: [IndexPath] = (originalAttributes.indexPath.item..(_ old: T, _ new: T) { 201 | if old != new { invalidateLayout() } 202 | } 203 | 204 | private func layoutHeader(position: inout CGFloat, collectionView: UICollectionView, delegate: WaterfallLayoutDelegate, section: Int) { 205 | let columnCount = delegate.collectionViewLayout(for: section).column 206 | let headerHeight = self.headerHeight(for: section) 207 | let headerInset = self.headerInset(for: section) 208 | 209 | position += headerInset.top 210 | 211 | if headerHeight > 0 { 212 | let attributes = UICollectionViewLayoutAttributes(forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, with: [section, 0]) 213 | attributes.frame = CGRect( 214 | x: headerInset.left, 215 | y: position, 216 | width: collectionView.bounds.width - (headerInset.left + headerInset.right), 217 | height: headerHeight 218 | ) 219 | headersAttribute[section] = attributes 220 | allItemAttributes.append(attributes) 221 | 222 | position = attributes.frame.maxY + headerInset.bottom 223 | } 224 | 225 | position += sectionInset(for: section).top 226 | columnHeights[section] = Array(repeating: position, count: columnCount) 227 | } 228 | 229 | private func pickColumn(itemIndex: Int, 230 | delegate: WaterfallLayoutDelegate, 231 | section: Int) -> Int { 232 | 233 | let layout = delegate.collectionViewLayout(for: section) 234 | switch layout { 235 | case .flow: 236 | let columnCount = delegate.collectionViewLayout(for: section).column 237 | return itemIndex % columnCount 238 | case .waterfall(_, let distributionMethod): 239 | if distributionMethod == .balanced { 240 | var minIndex: Int = 0 241 | var minValue = CGFloat.greatestFiniteMagnitude 242 | columnHeights[section].enumerated().forEach { (index, element) in 243 | if element < minValue { 244 | minIndex = index 245 | minValue = element 246 | } 247 | } 248 | return minIndex 249 | } else { 250 | let columnCount = delegate.collectionViewLayout(for: section).column 251 | return itemIndex % columnCount 252 | } 253 | } 254 | } 255 | 256 | private func layoutItems(position: CGFloat, collectionView: UICollectionView, delegate: WaterfallLayoutDelegate, section: Int) { 257 | let sectionInset = self.sectionInset(for: section) 258 | let minimumInteritemSpacing = self.minimumInteritemSpacing(for: section) 259 | let minimumLineSpacing = self.minimumInteritemSpacing(for: section) 260 | 261 | let columnCount = delegate.collectionViewLayout(for: section).column 262 | let itemCount = collectionView.numberOfItems(inSection: section) 263 | let width = collectionView.bounds.width - (sectionInset.left + sectionInset.right) 264 | let itemWidth = floor((width - CGFloat(columnCount - 1) * minimumLineSpacing) / CGFloat(columnCount)) 265 | let paddingLeft = itemWidth + minimumLineSpacing 266 | 267 | var itemAttributes: [UICollectionViewLayoutAttributes] = [] 268 | 269 | (0.. 0 && itemSize.width > 0 ? floor(itemSize.height * itemWidth / itemSize.width) : 0.0 281 | } 282 | 283 | 284 | let offsetY: CGFloat 285 | let layout = delegate.collectionViewLayout(for: section) 286 | switch layout { 287 | case .flow: 288 | offsetY = index < columnCount ? position : columnHeights[section][columnIndex] 289 | case .waterfall: 290 | offsetY = columnHeights[section][columnIndex] 291 | } 292 | 293 | let attributes = UICollectionViewLayoutAttributes(forCellWith: indexPath) 294 | attributes.frame = CGRect( 295 | x: sectionInset.left + paddingLeft * CGFloat(columnIndex), 296 | y: offsetY, 297 | width: itemWidth, 298 | height: itemHeight 299 | ) 300 | itemAttributes.append(attributes) 301 | columnHeights[section][columnIndex] = attributes.frame.maxY + minimumInteritemSpacing 302 | 303 | if case .flow = layout, index % columnCount == columnCount - 1 { 304 | let maxHeight = columnHeights[section].enumerated().sorted { $0.element > $1.element }.first?.element ?? 0.0 305 | columnHeights[section] = Array(repeating: maxHeight, count: columnCount) 306 | } 307 | } 308 | allItemAttributes.append(contentsOf: itemAttributes) 309 | sectionItemAttributes.append(itemAttributes) 310 | } 311 | 312 | private func layoutFooter(position: inout CGFloat, collectionView: UICollectionView, delegate: WaterfallLayoutDelegate, section: Int) { 313 | let sectionInset = self.sectionInset(for: section) 314 | let minimumInteritemSpacing = self.minimumInteritemSpacing(for: section) 315 | let columnCount = delegate.collectionViewLayout(for: section).column 316 | let longestColumnIndex = columnHeights[section].enumerated().sorted { $0.element > $1.element }.first?.offset ?? 0 317 | 318 | if columnHeights[section].count > 0 { 319 | position = columnHeights[section][longestColumnIndex] - minimumInteritemSpacing + sectionInset.bottom 320 | } else { 321 | position = 0.0 322 | } 323 | let footerHeight = self.footerHeight(for: section) 324 | let footerInset = self.footerInset(for: section) 325 | position += footerInset.top 326 | 327 | if footerHeight > 0.0 { 328 | let attributes = UICollectionViewLayoutAttributes(forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter, with: [section, 0]) 329 | attributes.frame = CGRect(x: footerInset.left, y: position, width: collectionView.bounds.width - (footerInset.left + footerInset.right), height: footerHeight) 330 | footersAttribute[section] = attributes 331 | allItemAttributes.append(attributes) 332 | position = attributes.frame.maxY + footerInset.bottom 333 | } 334 | columnHeights[section] = Array(repeating: position, count: columnCount) 335 | } 336 | 337 | private func minimumInteritemSpacing(for section: Int) -> CGFloat { 338 | return collectionView.flatMap { delegate?.collectionView($0, layout: self, minimumInteritemSpacingFor: section) } ?? minimumInteritemSpacing 339 | } 340 | 341 | private func minimumLineSpacing(for section: Int) -> CGFloat { 342 | return collectionView.flatMap { delegate?.collectionView($0, layout: self, minimumLineSpacingFor: section) } ?? minimumLineSpacing 343 | } 344 | 345 | private func sectionInset(for section: Int) -> UIEdgeInsets { 346 | return collectionView.flatMap { delegate?.collectionView($0, layout: self, sectionInsetFor: section) } ?? sectionInset 347 | } 348 | 349 | private func headerHeight(for section: Int) -> CGFloat { 350 | return collectionView.flatMap { delegate?.collectionView($0, layout: self, headerHeightFor: section) } ?? headerHeight 351 | } 352 | 353 | private func headerInset(for section: Int) -> UIEdgeInsets { 354 | return collectionView.flatMap { delegate?.collectionView($0, layout: self, headerInsetFor: section) } ?? headerInset 355 | } 356 | 357 | private func footerHeight(for section: Int) -> CGFloat { 358 | return collectionView.flatMap { delegate?.collectionView($0, layout: self, footerHeightFor: section) } ?? footerHeight 359 | } 360 | 361 | private func footerInset(for section: Int) -> UIEdgeInsets { 362 | return collectionView.flatMap { delegate?.collectionView($0, layout: self, footerInsetFor: section) } ?? footerInset 363 | } 364 | 365 | private func estimatedSizeForItemAt(_ indexPath: IndexPath) -> CGSize { 366 | return collectionView.flatMap { delegate?.collectionView($0, layout: self, estimatedSizeForItemAt: indexPath) } ?? estimatedItemSize 367 | } 368 | } 369 | 370 | -------------------------------------------------------------------------------- /WaterfallLayout.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "WaterfallLayout" 3 | s.version = "0.2" 4 | s.summary = "Generate ElasticSearch query in Swift" 5 | s.homepage = "https://github.com/sgr-ksmt/WaterfallLayout" 6 | # s.screenshots = "" 7 | s.license = 'MIT' 8 | s.author = { "Suguru Kishimoto" => "melodydance.k.s@gmail.com" } 9 | s.source = { :git => "https://github.com/sgr-ksmt/WaterfallLayout.git", :tag => s.version.to_s } 10 | s.platform = :ios, '9.0' 11 | s.requires_arc = true 12 | s.source_files = "Sources/**/*" 13 | s.swift_version = '4.2' 14 | end 15 | -------------------------------------------------------------------------------- /WaterfallLayout.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 48; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 163D51ED1F83791D00580844 /* WaterfallLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = 163D51EB1F83791D00580844 /* WaterfallLayout.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | 16BFDC8E1F837BB50035B802 /* WaterfallLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16BFDC8D1F837BB50035B802 /* WaterfallLayout.swift */; }; 12 | 16BFDC961F8382C50035B802 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16BFDC951F8382C50035B802 /* AppDelegate.swift */; }; 13 | 16BFDC981F8382C50035B802 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16BFDC971F8382C50035B802 /* ViewController.swift */; }; 14 | 16BFDC9B1F8382C50035B802 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 16BFDC991F8382C50035B802 /* Main.storyboard */; }; 15 | 16BFDC9D1F8382C50035B802 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 16BFDC9C1F8382C50035B802 /* Assets.xcassets */; }; 16 | 16BFDCA01F8382C50035B802 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 16BFDC9E1F8382C50035B802 /* LaunchScreen.storyboard */; }; 17 | 16BFDCA61F8385700035B802 /* DataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16BFDCA51F8385700035B802 /* DataSource.swift */; }; 18 | 16BFDCA81F8393700035B802 /* test_data.json in Resources */ = {isa = PBXBuildFile; fileRef = 16BFDCA71F8387C20035B802 /* test_data.json */; }; 19 | 16BFDCAC1F8476BD0035B802 /* ColorCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16BFDCAB1F8476BD0035B802 /* ColorCell.swift */; }; 20 | 16BFDCAE1F847AF90035B802 /* TextCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16BFDCAD1F847AF90035B802 /* TextCell.swift */; }; 21 | 16BFDCB01F847B640035B802 /* TextCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 16BFDCAF1F847B640035B802 /* TextCell.xib */; }; 22 | 16BFDCB11F84815E0035B802 /* WaterfallLayout.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 163D51E81F83791D00580844 /* WaterfallLayout.framework */; }; 23 | 16BFDCB21F84815E0035B802 /* WaterfallLayout.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 163D51E81F83791D00580844 /* WaterfallLayout.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 24 | 16BFDCB71F84A0190035B802 /* HeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16BFDCB61F84A0190035B802 /* HeaderView.swift */; }; 25 | 16BFDCB91F84A1730035B802 /* HeaderView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 16BFDCB81F84A1730035B802 /* HeaderView.xib */; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXContainerItemProxy section */ 29 | 16BFDCB31F84815E0035B802 /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = 163D51DF1F83791D00580844 /* Project object */; 32 | proxyType = 1; 33 | remoteGlobalIDString = 163D51E71F83791D00580844; 34 | remoteInfo = WaterfallLayout; 35 | }; 36 | /* End PBXContainerItemProxy section */ 37 | 38 | /* Begin PBXCopyFilesBuildPhase section */ 39 | 16BFDCB51F84815E0035B802 /* Embed Frameworks */ = { 40 | isa = PBXCopyFilesBuildPhase; 41 | buildActionMask = 2147483647; 42 | dstPath = ""; 43 | dstSubfolderSpec = 10; 44 | files = ( 45 | 16BFDCB21F84815E0035B802 /* WaterfallLayout.framework in Embed Frameworks */, 46 | ); 47 | name = "Embed Frameworks"; 48 | runOnlyForDeploymentPostprocessing = 0; 49 | }; 50 | /* End PBXCopyFilesBuildPhase section */ 51 | 52 | /* Begin PBXFileReference section */ 53 | 163D51E81F83791D00580844 /* WaterfallLayout.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = WaterfallLayout.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 54 | 163D51EB1F83791D00580844 /* WaterfallLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WaterfallLayout.h; sourceTree = ""; }; 55 | 163D51EC1F83791D00580844 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 56 | 16BFDC8D1F837BB50035B802 /* WaterfallLayout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WaterfallLayout.swift; sourceTree = ""; }; 57 | 16BFDC931F8382C50035B802 /* Demo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Demo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 58 | 16BFDC951F8382C50035B802 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 59 | 16BFDC971F8382C50035B802 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 60 | 16BFDC9A1F8382C50035B802 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 61 | 16BFDC9C1F8382C50035B802 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 62 | 16BFDC9F1F8382C50035B802 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 63 | 16BFDCA11F8382C50035B802 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 64 | 16BFDCA51F8385700035B802 /* DataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataSource.swift; sourceTree = ""; }; 65 | 16BFDCA71F8387C20035B802 /* test_data.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = test_data.json; sourceTree = ""; }; 66 | 16BFDCAB1F8476BD0035B802 /* ColorCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ColorCell.swift; sourceTree = ""; }; 67 | 16BFDCAD1F847AF90035B802 /* TextCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextCell.swift; sourceTree = ""; }; 68 | 16BFDCAF1F847B640035B802 /* TextCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TextCell.xib; sourceTree = ""; }; 69 | 16BFDCB61F84A0190035B802 /* HeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderView.swift; sourceTree = ""; }; 70 | 16BFDCB81F84A1730035B802 /* HeaderView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = HeaderView.xib; sourceTree = ""; }; 71 | /* End PBXFileReference section */ 72 | 73 | /* Begin PBXFrameworksBuildPhase section */ 74 | 163D51E41F83791D00580844 /* Frameworks */ = { 75 | isa = PBXFrameworksBuildPhase; 76 | buildActionMask = 2147483647; 77 | files = ( 78 | ); 79 | runOnlyForDeploymentPostprocessing = 0; 80 | }; 81 | 16BFDC901F8382C50035B802 /* Frameworks */ = { 82 | isa = PBXFrameworksBuildPhase; 83 | buildActionMask = 2147483647; 84 | files = ( 85 | 16BFDCB11F84815E0035B802 /* WaterfallLayout.framework in Frameworks */, 86 | ); 87 | runOnlyForDeploymentPostprocessing = 0; 88 | }; 89 | /* End PBXFrameworksBuildPhase section */ 90 | 91 | /* Begin PBXGroup section */ 92 | 163D51DE1F83791D00580844 = { 93 | isa = PBXGroup; 94 | children = ( 95 | 16BFDC8C1F837B8D0035B802 /* Sources */, 96 | 163D51EA1F83791D00580844 /* WaterfallLayout */, 97 | 16BFDC941F8382C50035B802 /* Demo */, 98 | 163D51E91F83791D00580844 /* Products */, 99 | 16BFDCA91F839A860035B802 /* Frameworks */, 100 | ); 101 | sourceTree = ""; 102 | }; 103 | 163D51E91F83791D00580844 /* Products */ = { 104 | isa = PBXGroup; 105 | children = ( 106 | 163D51E81F83791D00580844 /* WaterfallLayout.framework */, 107 | 16BFDC931F8382C50035B802 /* Demo.app */, 108 | ); 109 | name = Products; 110 | sourceTree = ""; 111 | }; 112 | 163D51EA1F83791D00580844 /* WaterfallLayout */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 163D51EB1F83791D00580844 /* WaterfallLayout.h */, 116 | 163D51EC1F83791D00580844 /* Info.plist */, 117 | ); 118 | path = WaterfallLayout; 119 | sourceTree = ""; 120 | }; 121 | 16BFDC8C1F837B8D0035B802 /* Sources */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | 16BFDC8D1F837BB50035B802 /* WaterfallLayout.swift */, 125 | ); 126 | path = Sources; 127 | sourceTree = ""; 128 | }; 129 | 16BFDC941F8382C50035B802 /* Demo */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | 16BFDCA71F8387C20035B802 /* test_data.json */, 133 | 16BFDC951F8382C50035B802 /* AppDelegate.swift */, 134 | 16BFDC971F8382C50035B802 /* ViewController.swift */, 135 | 16BFDC991F8382C50035B802 /* Main.storyboard */, 136 | 16BFDC9C1F8382C50035B802 /* Assets.xcassets */, 137 | 16BFDC9E1F8382C50035B802 /* LaunchScreen.storyboard */, 138 | 16BFDCA11F8382C50035B802 /* Info.plist */, 139 | 16BFDCA51F8385700035B802 /* DataSource.swift */, 140 | 16BFDCAB1F8476BD0035B802 /* ColorCell.swift */, 141 | 16BFDCAD1F847AF90035B802 /* TextCell.swift */, 142 | 16BFDCAF1F847B640035B802 /* TextCell.xib */, 143 | 16BFDCB61F84A0190035B802 /* HeaderView.swift */, 144 | 16BFDCB81F84A1730035B802 /* HeaderView.xib */, 145 | ); 146 | path = Demo; 147 | sourceTree = ""; 148 | }; 149 | 16BFDCA91F839A860035B802 /* Frameworks */ = { 150 | isa = PBXGroup; 151 | children = ( 152 | ); 153 | name = Frameworks; 154 | sourceTree = ""; 155 | }; 156 | /* End PBXGroup section */ 157 | 158 | /* Begin PBXHeadersBuildPhase section */ 159 | 163D51E51F83791D00580844 /* Headers */ = { 160 | isa = PBXHeadersBuildPhase; 161 | buildActionMask = 2147483647; 162 | files = ( 163 | 163D51ED1F83791D00580844 /* WaterfallLayout.h in Headers */, 164 | ); 165 | runOnlyForDeploymentPostprocessing = 0; 166 | }; 167 | /* End PBXHeadersBuildPhase section */ 168 | 169 | /* Begin PBXNativeTarget section */ 170 | 163D51E71F83791D00580844 /* WaterfallLayout */ = { 171 | isa = PBXNativeTarget; 172 | buildConfigurationList = 163D51F01F83791D00580844 /* Build configuration list for PBXNativeTarget "WaterfallLayout" */; 173 | buildPhases = ( 174 | 163D51E31F83791D00580844 /* Sources */, 175 | 163D51E41F83791D00580844 /* Frameworks */, 176 | 163D51E51F83791D00580844 /* Headers */, 177 | 163D51E61F83791D00580844 /* Resources */, 178 | ); 179 | buildRules = ( 180 | ); 181 | dependencies = ( 182 | ); 183 | name = WaterfallLayout; 184 | productName = WaterfallLayout; 185 | productReference = 163D51E81F83791D00580844 /* WaterfallLayout.framework */; 186 | productType = "com.apple.product-type.framework"; 187 | }; 188 | 16BFDC921F8382C50035B802 /* Demo */ = { 189 | isa = PBXNativeTarget; 190 | buildConfigurationList = 16BFDCA21F8382C50035B802 /* Build configuration list for PBXNativeTarget "Demo" */; 191 | buildPhases = ( 192 | 16BFDC8F1F8382C50035B802 /* Sources */, 193 | 16BFDC901F8382C50035B802 /* Frameworks */, 194 | 16BFDC911F8382C50035B802 /* Resources */, 195 | 16BFDCB51F84815E0035B802 /* Embed Frameworks */, 196 | ); 197 | buildRules = ( 198 | ); 199 | dependencies = ( 200 | 16BFDCB41F84815E0035B802 /* PBXTargetDependency */, 201 | ); 202 | name = Demo; 203 | productName = Demo; 204 | productReference = 16BFDC931F8382C50035B802 /* Demo.app */; 205 | productType = "com.apple.product-type.application"; 206 | }; 207 | /* End PBXNativeTarget section */ 208 | 209 | /* Begin PBXProject section */ 210 | 163D51DF1F83791D00580844 /* Project object */ = { 211 | isa = PBXProject; 212 | attributes = { 213 | LastSwiftUpdateCheck = 0900; 214 | LastUpgradeCheck = 1000; 215 | ORGANIZATIONNAME = "Suguru Kishimoto"; 216 | TargetAttributes = { 217 | 163D51E71F83791D00580844 = { 218 | CreatedOnToolsVersion = 9.0; 219 | LastSwiftMigration = 1000; 220 | ProvisioningStyle = Automatic; 221 | }; 222 | 16BFDC921F8382C50035B802 = { 223 | CreatedOnToolsVersion = 9.0; 224 | ProvisioningStyle = Automatic; 225 | }; 226 | }; 227 | }; 228 | buildConfigurationList = 163D51E21F83791D00580844 /* Build configuration list for PBXProject "WaterfallLayout" */; 229 | compatibilityVersion = "Xcode 8.0"; 230 | developmentRegion = en; 231 | hasScannedForEncodings = 0; 232 | knownRegions = ( 233 | en, 234 | Base, 235 | ); 236 | mainGroup = 163D51DE1F83791D00580844; 237 | productRefGroup = 163D51E91F83791D00580844 /* Products */; 238 | projectDirPath = ""; 239 | projectRoot = ""; 240 | targets = ( 241 | 163D51E71F83791D00580844 /* WaterfallLayout */, 242 | 16BFDC921F8382C50035B802 /* Demo */, 243 | ); 244 | }; 245 | /* End PBXProject section */ 246 | 247 | /* Begin PBXResourcesBuildPhase section */ 248 | 163D51E61F83791D00580844 /* Resources */ = { 249 | isa = PBXResourcesBuildPhase; 250 | buildActionMask = 2147483647; 251 | files = ( 252 | ); 253 | runOnlyForDeploymentPostprocessing = 0; 254 | }; 255 | 16BFDC911F8382C50035B802 /* Resources */ = { 256 | isa = PBXResourcesBuildPhase; 257 | buildActionMask = 2147483647; 258 | files = ( 259 | 16BFDCA01F8382C50035B802 /* LaunchScreen.storyboard in Resources */, 260 | 16BFDC9D1F8382C50035B802 /* Assets.xcassets in Resources */, 261 | 16BFDCB01F847B640035B802 /* TextCell.xib in Resources */, 262 | 16BFDCB91F84A1730035B802 /* HeaderView.xib in Resources */, 263 | 16BFDC9B1F8382C50035B802 /* Main.storyboard in Resources */, 264 | 16BFDCA81F8393700035B802 /* test_data.json in Resources */, 265 | ); 266 | runOnlyForDeploymentPostprocessing = 0; 267 | }; 268 | /* End PBXResourcesBuildPhase section */ 269 | 270 | /* Begin PBXSourcesBuildPhase section */ 271 | 163D51E31F83791D00580844 /* Sources */ = { 272 | isa = PBXSourcesBuildPhase; 273 | buildActionMask = 2147483647; 274 | files = ( 275 | 16BFDC8E1F837BB50035B802 /* WaterfallLayout.swift in Sources */, 276 | ); 277 | runOnlyForDeploymentPostprocessing = 0; 278 | }; 279 | 16BFDC8F1F8382C50035B802 /* Sources */ = { 280 | isa = PBXSourcesBuildPhase; 281 | buildActionMask = 2147483647; 282 | files = ( 283 | 16BFDCAE1F847AF90035B802 /* TextCell.swift in Sources */, 284 | 16BFDCB71F84A0190035B802 /* HeaderView.swift in Sources */, 285 | 16BFDCA61F8385700035B802 /* DataSource.swift in Sources */, 286 | 16BFDCAC1F8476BD0035B802 /* ColorCell.swift in Sources */, 287 | 16BFDC981F8382C50035B802 /* ViewController.swift in Sources */, 288 | 16BFDC961F8382C50035B802 /* AppDelegate.swift in Sources */, 289 | ); 290 | runOnlyForDeploymentPostprocessing = 0; 291 | }; 292 | /* End PBXSourcesBuildPhase section */ 293 | 294 | /* Begin PBXTargetDependency section */ 295 | 16BFDCB41F84815E0035B802 /* PBXTargetDependency */ = { 296 | isa = PBXTargetDependency; 297 | target = 163D51E71F83791D00580844 /* WaterfallLayout */; 298 | targetProxy = 16BFDCB31F84815E0035B802 /* PBXContainerItemProxy */; 299 | }; 300 | /* End PBXTargetDependency section */ 301 | 302 | /* Begin PBXVariantGroup section */ 303 | 16BFDC991F8382C50035B802 /* Main.storyboard */ = { 304 | isa = PBXVariantGroup; 305 | children = ( 306 | 16BFDC9A1F8382C50035B802 /* Base */, 307 | ); 308 | name = Main.storyboard; 309 | sourceTree = ""; 310 | }; 311 | 16BFDC9E1F8382C50035B802 /* LaunchScreen.storyboard */ = { 312 | isa = PBXVariantGroup; 313 | children = ( 314 | 16BFDC9F1F8382C50035B802 /* Base */, 315 | ); 316 | name = LaunchScreen.storyboard; 317 | sourceTree = ""; 318 | }; 319 | /* End PBXVariantGroup section */ 320 | 321 | /* Begin XCBuildConfiguration section */ 322 | 163D51EE1F83791D00580844 /* Debug */ = { 323 | isa = XCBuildConfiguration; 324 | buildSettings = { 325 | ALWAYS_SEARCH_USER_PATHS = NO; 326 | CLANG_ANALYZER_NONNULL = YES; 327 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 328 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 329 | CLANG_CXX_LIBRARY = "libc++"; 330 | CLANG_ENABLE_MODULES = YES; 331 | CLANG_ENABLE_OBJC_ARC = YES; 332 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 333 | CLANG_WARN_BOOL_CONVERSION = YES; 334 | CLANG_WARN_COMMA = YES; 335 | CLANG_WARN_CONSTANT_CONVERSION = YES; 336 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 337 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 338 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 339 | CLANG_WARN_EMPTY_BODY = YES; 340 | CLANG_WARN_ENUM_CONVERSION = YES; 341 | CLANG_WARN_INFINITE_RECURSION = YES; 342 | CLANG_WARN_INT_CONVERSION = YES; 343 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 344 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 345 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 346 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 347 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 348 | CLANG_WARN_STRICT_PROTOTYPES = YES; 349 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 350 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 351 | CLANG_WARN_UNREACHABLE_CODE = YES; 352 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 353 | CODE_SIGN_IDENTITY = "iPhone Developer"; 354 | COPY_PHASE_STRIP = NO; 355 | CURRENT_PROJECT_VERSION = 1; 356 | DEBUG_INFORMATION_FORMAT = dwarf; 357 | ENABLE_STRICT_OBJC_MSGSEND = YES; 358 | ENABLE_TESTABILITY = YES; 359 | GCC_C_LANGUAGE_STANDARD = gnu11; 360 | GCC_DYNAMIC_NO_PIC = NO; 361 | GCC_NO_COMMON_BLOCKS = YES; 362 | GCC_OPTIMIZATION_LEVEL = 0; 363 | GCC_PREPROCESSOR_DEFINITIONS = ( 364 | "DEBUG=1", 365 | "$(inherited)", 366 | ); 367 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 368 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 369 | GCC_WARN_UNDECLARED_SELECTOR = YES; 370 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 371 | GCC_WARN_UNUSED_FUNCTION = YES; 372 | GCC_WARN_UNUSED_VARIABLE = YES; 373 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 374 | MTL_ENABLE_DEBUG_INFO = YES; 375 | ONLY_ACTIVE_ARCH = YES; 376 | SDKROOT = iphoneos; 377 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 378 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 379 | SWIFT_VERSION = 4.2; 380 | VERSIONING_SYSTEM = "apple-generic"; 381 | VERSION_INFO_PREFIX = ""; 382 | }; 383 | name = Debug; 384 | }; 385 | 163D51EF1F83791D00580844 /* Release */ = { 386 | isa = XCBuildConfiguration; 387 | buildSettings = { 388 | ALWAYS_SEARCH_USER_PATHS = NO; 389 | CLANG_ANALYZER_NONNULL = YES; 390 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 391 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 392 | CLANG_CXX_LIBRARY = "libc++"; 393 | CLANG_ENABLE_MODULES = YES; 394 | CLANG_ENABLE_OBJC_ARC = YES; 395 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 396 | CLANG_WARN_BOOL_CONVERSION = YES; 397 | CLANG_WARN_COMMA = YES; 398 | CLANG_WARN_CONSTANT_CONVERSION = YES; 399 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 400 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 401 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 402 | CLANG_WARN_EMPTY_BODY = YES; 403 | CLANG_WARN_ENUM_CONVERSION = YES; 404 | CLANG_WARN_INFINITE_RECURSION = YES; 405 | CLANG_WARN_INT_CONVERSION = YES; 406 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 407 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 408 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 409 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 410 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 411 | CLANG_WARN_STRICT_PROTOTYPES = YES; 412 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 413 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 414 | CLANG_WARN_UNREACHABLE_CODE = YES; 415 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 416 | CODE_SIGN_IDENTITY = "iPhone Developer"; 417 | COPY_PHASE_STRIP = NO; 418 | CURRENT_PROJECT_VERSION = 1; 419 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 420 | ENABLE_NS_ASSERTIONS = NO; 421 | ENABLE_STRICT_OBJC_MSGSEND = YES; 422 | GCC_C_LANGUAGE_STANDARD = gnu11; 423 | GCC_NO_COMMON_BLOCKS = YES; 424 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 425 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 426 | GCC_WARN_UNDECLARED_SELECTOR = YES; 427 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 428 | GCC_WARN_UNUSED_FUNCTION = YES; 429 | GCC_WARN_UNUSED_VARIABLE = YES; 430 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 431 | MTL_ENABLE_DEBUG_INFO = NO; 432 | SDKROOT = iphoneos; 433 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 434 | SWIFT_VERSION = 4.2; 435 | VALIDATE_PRODUCT = YES; 436 | VERSIONING_SYSTEM = "apple-generic"; 437 | VERSION_INFO_PREFIX = ""; 438 | }; 439 | name = Release; 440 | }; 441 | 163D51F11F83791D00580844 /* Debug */ = { 442 | isa = XCBuildConfiguration; 443 | buildSettings = { 444 | CLANG_ENABLE_MODULES = YES; 445 | CODE_SIGN_IDENTITY = ""; 446 | CODE_SIGN_STYLE = Automatic; 447 | DEFINES_MODULE = YES; 448 | DYLIB_COMPATIBILITY_VERSION = 1; 449 | DYLIB_CURRENT_VERSION = 1; 450 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 451 | INFOPLIST_FILE = WaterfallLayout/Info.plist; 452 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 453 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 454 | PRODUCT_BUNDLE_IDENTIFIER = "-.WaterfallLayout"; 455 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 456 | SKIP_INSTALL = YES; 457 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 458 | SWIFT_VERSION = 4.2; 459 | TARGETED_DEVICE_FAMILY = "1,2"; 460 | }; 461 | name = Debug; 462 | }; 463 | 163D51F21F83791D00580844 /* Release */ = { 464 | isa = XCBuildConfiguration; 465 | buildSettings = { 466 | CLANG_ENABLE_MODULES = YES; 467 | CODE_SIGN_IDENTITY = ""; 468 | CODE_SIGN_STYLE = Automatic; 469 | DEFINES_MODULE = YES; 470 | DYLIB_COMPATIBILITY_VERSION = 1; 471 | DYLIB_CURRENT_VERSION = 1; 472 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 473 | INFOPLIST_FILE = WaterfallLayout/Info.plist; 474 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 475 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 476 | PRODUCT_BUNDLE_IDENTIFIER = "-.WaterfallLayout"; 477 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 478 | SKIP_INSTALL = YES; 479 | SWIFT_VERSION = 4.2; 480 | TARGETED_DEVICE_FAMILY = "1,2"; 481 | }; 482 | name = Release; 483 | }; 484 | 16BFDCA31F8382C50035B802 /* Debug */ = { 485 | isa = XCBuildConfiguration; 486 | buildSettings = { 487 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 488 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 489 | CODE_SIGN_STYLE = Automatic; 490 | INFOPLIST_FILE = Demo/Info.plist; 491 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 492 | PRODUCT_BUNDLE_IDENTIFIER = "-.Demo"; 493 | PRODUCT_NAME = "$(TARGET_NAME)"; 494 | SWIFT_VERSION = 4.2; 495 | TARGETED_DEVICE_FAMILY = "1,2"; 496 | }; 497 | name = Debug; 498 | }; 499 | 16BFDCA41F8382C50035B802 /* Release */ = { 500 | isa = XCBuildConfiguration; 501 | buildSettings = { 502 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 503 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 504 | CODE_SIGN_STYLE = Automatic; 505 | INFOPLIST_FILE = Demo/Info.plist; 506 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 507 | PRODUCT_BUNDLE_IDENTIFIER = "-.Demo"; 508 | PRODUCT_NAME = "$(TARGET_NAME)"; 509 | SWIFT_VERSION = 4.2; 510 | TARGETED_DEVICE_FAMILY = "1,2"; 511 | }; 512 | name = Release; 513 | }; 514 | /* End XCBuildConfiguration section */ 515 | 516 | /* Begin XCConfigurationList section */ 517 | 163D51E21F83791D00580844 /* Build configuration list for PBXProject "WaterfallLayout" */ = { 518 | isa = XCConfigurationList; 519 | buildConfigurations = ( 520 | 163D51EE1F83791D00580844 /* Debug */, 521 | 163D51EF1F83791D00580844 /* Release */, 522 | ); 523 | defaultConfigurationIsVisible = 0; 524 | defaultConfigurationName = Release; 525 | }; 526 | 163D51F01F83791D00580844 /* Build configuration list for PBXNativeTarget "WaterfallLayout" */ = { 527 | isa = XCConfigurationList; 528 | buildConfigurations = ( 529 | 163D51F11F83791D00580844 /* Debug */, 530 | 163D51F21F83791D00580844 /* Release */, 531 | ); 532 | defaultConfigurationIsVisible = 0; 533 | defaultConfigurationName = Release; 534 | }; 535 | 16BFDCA21F8382C50035B802 /* Build configuration list for PBXNativeTarget "Demo" */ = { 536 | isa = XCConfigurationList; 537 | buildConfigurations = ( 538 | 16BFDCA31F8382C50035B802 /* Debug */, 539 | 16BFDCA41F8382C50035B802 /* Release */, 540 | ); 541 | defaultConfigurationIsVisible = 0; 542 | defaultConfigurationName = Release; 543 | }; 544 | /* End XCConfigurationList section */ 545 | }; 546 | rootObject = 163D51DF1F83791D00580844 /* Project object */; 547 | } 548 | -------------------------------------------------------------------------------- /WaterfallLayout.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /WaterfallLayout.xcodeproj/xcshareddata/xcschemes/Demo.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 | -------------------------------------------------------------------------------- /WaterfallLayout.xcodeproj/xcshareddata/xcschemes/WaterfallLayout.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /WaterfallLayout.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /WaterfallLayout/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 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 | -------------------------------------------------------------------------------- /WaterfallLayout/WaterfallLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // WaterfallLayout.h 3 | // WaterfallLayout 4 | // 5 | // Created by suguru-kishimoto on 2017/10/03. 6 | // Copyright © 2017年 Suguru Kishimoto. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for WaterfallLayout. 12 | FOUNDATION_EXPORT double WaterfallLayoutVersionNumber; 13 | 14 | //! Project version string for WaterfallLayout. 15 | FOUNDATION_EXPORT const unsigned char WaterfallLayoutVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgr-ksmt/WaterfallLayout/801268364ddfd13598b5589cd02c228fccb35e40/demo.gif -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgr-ksmt/WaterfallLayout/801268364ddfd13598b5589cd02c228fccb35e40/logo.png --------------------------------------------------------------------------------