This project was inspired by CSStickyHeaderFlowLayout. Here you can find a swift translation of both - layout and examples. Just build and check it out.
Types of headers which you can find here:
Parallax header:
Sticky header:
Growing header:
AlwaysOnTop header:
Move CSStickyHeaderFlowLayout.swift and CSStickyHeaderFlowLayoutAttributes.swift into your project then configure constraints using one of the examples in .xib files.
You may also need to make CSStickyHeaderFlowLayout your collectionView layout. You can do that in viewDidLoad:
private var layout : CSStickyHeaderFlowLayout? {
return self.collectionView?.collectionViewLayout as? CSStickyHeaderFlowLayout
}
override func viewDidLoad() {
super.viewDidLoad()
let headerNib = UINib(nibName: "CSParallaxHeader", bundle: nil)
self.collectionView?.register(headerNib, forSupplementaryViewOfKind: CSStickyHeaderParallaxHeader, withReuseIdentifier: "header")
self.layout?.parallaxHeaderReferenceSize = CGSize(width: self.view.frame.size.width, height: 100)
}
Cocoapods support, carthage support