IOStickyHeader
IOStickyHeader copied to clipboard
Parallax and Sticky header done right using UICollectionViewLayout
I migrated CSStickyHeaderFlowLayout library (Obj-C) to swift3.0
IOStickyHeader

Parallax, Sticky Headers, Growing image heading, done right in one UICollectionViewLayout.
Usage
To run the example project, clone the repo, and run pod install
from the Example directory first.
Don't forget to set your flow layout with IOStickyHeader in your storyboard

Register that nib file to your collection view controller in code:
import IOStickyHeader
let headerNib = UINib(nibName: "IOGrowHeader", bundle: NSBundle.mainBundle())
override func viewDidLoad() {
super.viewDidLoad()
self.collectionView.registerNib(self.headerNib, forSupplementaryViewOfKind: IOStickyHeaderParallaxHeader, withReuseIdentifier: "header")
}
Implement func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView
func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {
switch kind {
case IOStickyHeaderParallaxHeader:
let cell = collectionView.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier: "header", forIndexPath: indexPath) as! IOGrowHeader
return cell
default:
assert(false, "Unexpected element kind")
}
}
Requirements
- Swift 4.2
- iOS 9
Installation
CococaPods
IOStickyHeader is available through CocoaPods. To install it, simply add the following line to your Podfile:
use_frameworks!
pod "IOStickyHeader"
Carthage
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate IOStickyHeader into your Xcode project using Carthage, specify it in your Cartfile
:
github "BenjaminPrieur/IOStickyHeader"
Run carthage update
to build the framework and drag the built IOStickyHeader.framework
into your Xcode project.
Author
Benjamin Prieur
License
IOStickyHeader is available under the MIT license. See the LICENSE file for more info.