Latest 1.1.0
Homepage https://github.com/edwinps/CZCustomLayout
License MIT
Platforms ios 9.0
Frameworks Foundation, UIKit
Authors

Version
Platform
Build Status

CZCustomLayout is a subclass of UICollectionViewFlowLayout.

This layout is inspired by Pinterest, using CHTCollectionViewWaterfallLayout which allows you to use automatic sizes

Features

  • Easy to use.
  • Customizable.
  • Support header and footer views.
  • Custom column number for each sections.

Prerequisite

  • ARC
  • Xcode 7.1+.
  • iOS 9+

How to install

  • CocoaPods

    • Add pod 'CZCustomLayout' to your Podfile.
  • Manual
    • Copy BaseCollectionViewLayout.swift to your project.

How to Use

Step 1

import CZCustomLayout

In order to conform to the BaseCollectionViewLayoutProtocol protocol you have to adopt it in your UIViewController.

Step 2

To conform to the CZeyboardObserverDelegate you have to implement the following functions:

func collectionView (_ collectionView: UICollectionView, availableWidth: CGFloat, heightForItemAtIndexPath indexPath: IndexPath) -> CGFloat
--option--
func collectionView (_ collectionView: UICollectionView, availableWidth: CGFloat, heightForHeaderInSection section: Int) -> CGFloat
func collectionView (_ collectionView: UICollectionView, availableWidth: CGFloat, heightForFooterInSection section: Int) -> CGFloat
func collectionViewCellBigger(_ indexPath: IndexPath) -> Bool

Step 3

To config the layout in the viewcontroller

//create the Layout
let layout = BaseCollectionViewLayout()
//config margin
layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10)
// The minimum spacing to use between rows.
layout.minimumInteritemSpacing = 10
// The minimum spacing to use between columns
layout.minimumLineSpacing = 10
// number of columns
layout.numberOfColumns = 2
// Add the layout to your collection view
self.collectionView.collectionViewLayout = layout
//add delegate
layout.delegate = self

Limitation

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

License

CZCustomLayout is licensed under the MIT licence. See the LICENSE for more details.

Latest podspec

{
    "name": "CZCustomLayout",
    "version": "1.1.0",
    "summary": "Library with a custom layout for UICollectionView like pinterest style with a big item at first",
    "authors": {
        "Edwin Peu00f1a": "[email protected]"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/edwinps/CZCustomLayout.git",
        "tag": "1.1.0"
    },
    "source_files": "src/**/*.{swift}",
    "frameworks": [
        "Foundation",
        "UIKit"
    ],
    "homepage": "https://github.com/edwinps/CZCustomLayout",
    "license": {
        "type": "MIT",
        "file": "LICENSE.md"
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This