Latest 2.0.0
Homepage https://github.com/cruzdiego/HorizontalFloatingHeaderLayout
License MIT
Platforms ios 9.0, requires ARC
Frameworks UIKit
Authors

Version
License
Platform

Example.gif

HorizontalFLoatingHeaderLayout is a subclass of UICollectionViewLayout built with performance in mind. Born from the need for replicating UITableView’s sticky headers behavior and iOS 8+ native Emoji keyboard.

For a vertical implementation, you can turn on sectionHeadersPinToVisibleBounds flag from UICollectionViewFlowLayout (available since iOS 9.0)

What’s new in 2.0

  • Added support for Swift 4.0

Installation

Via CocoaPods:

pod "HorizontalFloatingHeaderLayout"

Manually:

  1. Clone this repo or download it as a .zip file
  2. Drag and drop HorizontalFloatingHeaderLayout.swift to your project

Usage

From Storyboard:

1. On your UICollectionView’s inspector, change its layout to "Custom" and type HorizontalFloatingHeaderLayout on the class field

HorizontalFloatingHeaderLayout

2. Import framework to your UIViewController subclass…

import HorizontalFloatingHeaderLayout

and make it conform protocol HorizontalFloatingHeaderLayoutDelegate

class YourViewController: UIViewController, HorizontalFloatingHeaderLayoutDelegate {

3. Implement all the necessary delegate methods.

Programatically:

1. Import framework to your UIViewController subclass

import HorizontalFloatingHeaderLayout

2. Instantiate and add to your UICollectionView object

collectionView.collectionViewLayout = HorizontalFloatingHeaderLayout()

3. Make your UIViewController subclass conform protocol HorizontalFloatingHeaderLayoutDelegate

class YourViewController: UIViewController, HorizontalFloatingHeaderLayoutDelegate {

4. Implement all the necessary delegate methods.

Delegate methods

//Item size
func collectionView(_ collectionView: UICollectionView,horizontalFloatingHeaderItemSizeAt indexPath:NSIndexPath) -> CGSize

Returns item size. Mandatory implementation.

//Header size
func collectionView(_ collectionView: UICollectionView, horizontalFloatingHeaderSizeAt section: Int) -> CGSize

Returns section’s header size. Mandatory implementation.

//Section Inset
optional func collectionView(_ collectionView: UICollectionView, horizontalFloatingHeaderSectionInsetForSectionAt section: Int) -> UIEdgeInsets

Returns section’s edge insets. Optional implementation. Default value is UIEdgeInsetsZero

//Item Spacing
optional func collectionView(_ collectionView: UICollectionView, horizontalFloatingHeaderItemSpacingForSectionAt section: Int) -> CGFloat

Returns point spacing between items on the same column. Optional implementation. Default value is 0.0.

//Line Spacing
optional func collectionView(_ collectionView: UICollectionView,horizontalFloatingHeaderColumnSpacingForSectionAt section: Int) -> CGFloat

Returns points spacing between columns. Optional implementation. Default value is 0.0.

Requirements

  • iOS 9.0
  • Xcode 8.0 or later (Uses Swift 4.0 syntax)

Author

Diego Cruz, [email protected]

License

HorizontalFloatingHeaderLayout is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "HorizontalFloatingHeaderLayout",
    "version": "2.0.0",
    "summary": "Floating headers with horizontal scrolling layout for UICollectionView, inspired by iOS native Emoji Keyboard layout",
    "description": "HorizontalFLoatingHeaderLayout is a subclass of UICollectionViewLayout built with performance in mind. Born from the need for replicating UITableView's sticky headers behavior and iOS 8+ native Emoji keyboard.nnFor a vertical implementation, you can turn on *sectionHeadersPinToVisibleBounds* flag from UICollectionViewFlowLayout (available since iOS 9.0)",
    "homepage": "https://github.com/cruzdiego/HorizontalFloatingHeaderLayout",
    "license": "MIT",
    "authors": {
        "Diego Cruz": "[email protected]"
    },
    "source": {
        "git": "https://github.com/cruzdiego/HorizontalFloatingHeaderLayout.git",
        "tag": "2.0.0"
    },
    "platforms": {
        "ios": "9.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "resource_bundles": {
        "HorizontalFloatingHeaderLayout": [
            "Pod/Assets/*.png"
        ]
    },
    "frameworks": "UIKit",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This