• Stars
    star
    4,467
  • Rank 9,457 (Top 0.2 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 12 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The waterfall (i.e., Pinterest-like) layout for UICollectionView.

CHTCollectionViewWaterfallLayout

Carthage compatible Swift Package Manager compatible Version Platform Build Status

CHTCollectionViewWaterfallLayout is a subclass of UICollectionViewLayout, and it trys to imitate UICollectionViewFlowLayout's usage as much as possible.

This layout is inspired by Pinterest.

Screen Shots

2 columns

Features

  • Easy to use, it tries to imitate UICollectionViewFlowLayout's usage as much as possible.
  • Highly customizable.
  • Outstanding performance, try 10,000+ items and see the smoothness for yourself.
  • Support header and footer views.
  • Different column counts in different sections.

Requirements

  • iOS 9+ / tvOS 9+
  • Objective-C or Swift 4.2

How to install

  • CocoaPods

    • Add pod 'CHTCollectionViewWaterfallLayout' to your Podfile.
    • If you prefer Objective-C, pod 'CHTCollectionViewWaterfallLayout/ObjC' is ready for you.
  • Carthage

    • Add github chiahsien/CHTCollectionViewWaterfallLayout to your Cartfile.
  • Swift Package Manager

    • Add it to the dependencies value of your Package.swift.
    dependencies: [
      .package(url: "https://github.com/chiahsien/CHTCollectionViewWaterfallLayout.git", from: "0.9.9")
    ]
    
  • Manual

    • Copy CHTCollectionViewWaterfallLayout.h/m or CHTCollectionViewWaterfallLayout.swift to your project.

How to Use

Read the demo codes and CHTCollectionViewWaterfallLayout.h header file for more information.

Step 1

Below lists the properties for you to customize the layout. Although they have default values, I strongly recommend you to set up at least the columnCount property to suit your needs. The itemRenderDirection property is an enum which decides the order in which your items will be rendered in subsequent rows. For eg. Left-Right | Right-Left | Shortest column filling up first.

@property (nonatomic, assign) NSInteger columnCount;
@property (nonatomic, assign) CGFloat minimumColumnSpacing;
@property (nonatomic, assign) CGFloat minimumInteritemSpacing;
@property (nonatomic, assign) CGFloat headerHeight;
@property (nonatomic, assign) CGFloat footerHeight;
@property (nonatomic, assign) UIEdgeInsets sectionInset;
@property (nonatomic, assign) ItemRenderDirection itemRenderDirection;

Step 2

Your collection view's delegate (which often is your view controller) must conforms to CHTCollectionViewDelegateWaterfallLayout protocol and implements the required method, all you need to do is return the original size of the item:

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath;

Limitation

  • Only vertical scrolling is supported.
  • No decoration view.

Who is using it

Please let me know if your app is using this library. I'm glad to put your app on the list :-)

  • F3PiX F3PiX is a series of apps which gives you a concise, curated collection of pictures by professional (Dutch) photographers according to a specific theme. You can use the pictures freely for your own work.
  • GroupMe for iOS GroupMe - A Home for All the Groups in Your Life.
  • Flickr Access and organize your photos from anywhere.
  • Tumblr Post whatever you want to your Tumblr. Follow other people who are doing the same. You’ll probably never be bored again.
  • Funliday The best trip planning app in the world!
  • Imgur Funny GIFs, Memes, and Images!
  • DealPad DealPad gives you access to the UK’s hottest Deals, Voucher Codes and Freebies in the palm of your hand.
  • Teespring Shopping Browse and purchase shirts, mugs, totes and more!

License

CHTCollectionViewWaterfallLayout is available under the MIT license. See the LICENSE file for more info.

Changelog

Refer to the Releases page.

More Repositories

1

AutoHighlightSymbol

A Xcode plugin to add highlight to the instances of selected symbol.
Objective-C
85
star
2

CHTStickerView

A movable, resizable, rotatable UIView with one fingle, which is fully customizable!
Objective-C
70
star
3

MarkViewer

A document based iOS app for viewing markdown files.
Swift
36
star
4

ReduxObjC

Redux-like template of the unidirectional data flow architecture in Objective-C.
Objective-C
35
star
5

CHTTextView

UITextView subclass that adds placeholder support like UITextField has.
Objective-C
25
star
6

CHTReachability

A real network reachability library for iOS.
Objective-C
18
star
7

JobHunter

一個練習 Swift Combine framework 的小專案,抓取知名平台們的職缺資料,方便使用者快速瀏覽尋找,並可連回該平台閱讀詳細資料。
Swift
15
star
8

What-Time

A pet project to train my kids to read analog clock face.
Swift
10
star
9

NSTimer-Block

Add block ability to NSTimer to avoid common retain cycle issues.
Objective-C
10
star
10

XcodeProjSorter

A command-line tool to sort Xcode's `.xcodeproj` file.
Swift
8
star
11

SwiftBeauty

Browse beautiful portraits swiftly.
Swift
5
star
12

SwiftUI-Beauty

Swift
5
star
13

RimeDayi

給中州韻輸入法用的大易字碼表
4
star
14

UnityInSwiftUI

This sample project shows how to show Unity view in SwiftUI, and how to establish bidirectional communication.
C++
4
star
15

chiahsien.github.io

This is my blog.
HTML
3
star
16

BlogBackupViewer

一個在 Windows 底下支援 MovableType 備份格式的閱讀器
Component Pascal
2
star
17

JobHunter-SwiftUI

Swift
2
star
18

sort-Xcode-project-file

A script to sort Xcode project file.
Perl
1
star
19

AFHTTPSessionManager-Essential

Essential template for AFHTTPSessionManager
Objective-C
1
star
20

iphonewavefrontloader

Automatically exported from code.google.com/p/iphonewavefrontloader
Objective-C
1
star