sti

StickyHeaderFlowLayout

Sticky headers for UICollectionView written in pure Swift (based on CSStickyHeaderFlowLayout)

Showing:

Popularity

Downloads/wk

0

GitHub Stars

144

Maintenance

Last Commit

2yrs ago

Contributors

0

Package

Dependencies

0

License

MIT

Categories

Readme

StickyHeaderFlowLayout

StickyHeaderFlowLayout

Sticky headers for UICollectionView written in pure Swift


Based on CSStickyHeaderFlowLayout. StickyHeaderFlowLayout makes it easy to create sticky headers in UICollectionView.

Integration

CocoaPods

You can use CocoaPods to install StickyHeaderFlowLayout by adding it to your Podfile:

platform :ios, '9.0'

target 'MyApp' do
    pod 'StickyHeaderFlowLayout'
end

Manually

To use this library in your project manually you may:

Just drag StickyHeaderFlowLayout.swift and StickyHeaderFlowLayoutAttributes.swift to the project tree

Usage

Sample project

Repository contains small sample project which shows basic integration.

Basic idea

  1. Create layout and collection view
let layout = StickyHeaderFlowLayout()
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
  1. Setup sticky header
collectionView.register(CollectionParallaxHeader.self, forSupplementaryViewOfKind: StickyHeaderFlowLayout.parallaxHeaderIdentifier, withReuseIdentifier: "parallaxHeader")
layout.parallaxHeaderReferenceSize = CGSize(width: view.frame.size.width, height: 200)
layout.parallaxHeaderMinimumReferenceSize = CGSize(width: view.frame.size.width, height: 160)
  1. Return correct view in viewForSupplementaryElementOfKind function
override func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
     if kind == StickyHeaderFlowLayout.parallaxHeaderIdentifier {
         return collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "parallaxHeader", for: indexPath)
     }
     
     // Other views.
     ...
}

License

StickyHeaderFlowLayout is released under the MIT license. See LICENSE for details.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100