CZCustomLayout is a subclass of UICollectionViewFlowLayout.
This layout is inspired by Pinterest, using CHTCollectionViewWaterfallLayout which allows you to use automatic sizes
- Easy to use.
- Customizable.
- Support header and footer views.
- Custom column number for each sections.
- ARC
- Xcode 7.1+.
- iOS 9+
-
- Add
pod 'CZCustomLayout'
to your Podfile.
- Add
-
Manual
- Copy
BaseCollectionViewLayout.swift
to your project.
- Copy
import CZCustomLayout
In order to conform to the BaseCollectionViewLayoutProtocol protocol you have to adopt it in your UIViewController.
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 collectionView (_ collectionView: UICollectionView, columnCountForSection section: Int) -> Int
func collectionViewBiggerCell(_ indexPath: IndexPath) -> Bool
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 or implement collectionView (_ collectionView: UICollectionView, columnCountForSection section: Int)
layout.numberOfColumns = 2
// Add the layout to your collection view
self.collectionView.collectionViewLayout = layout
//add delegate
layout.delegate = self
- Only vertical scrolling is supported.
- No decoration view.
CZCustomLayout is licensed under the MIT licence. See the LICENSE for more details.