Coder Social home page Coder Social logo

thangk48cc / horizontalfloatingheaderlayout Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cruzdiego/horizontalfloatingheaderlayout

1.0 1.0 0.0 3.46 MB

Floating headers with horizontal scrolling layout for UICollectionView, inspired by iOS native Emoji Keyboard layout

License: MIT License

Swift 48.35% Ruby 6.13% Objective-C 2.92% Shell 42.59%

horizontalfloatingheaderlayout's Introduction

HorizontalFloatingHeaderLayout

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)

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

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,horizontalFloatingHeaderItemSizeForItemAtIndexPath indexPath:NSIndexPath) -> CGSize

Returns item size. Mandatory implementation.

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

Returns section's header size. Mandatory implementation.

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

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

//Item Spacing
optional func collectionView(collectionView: UICollectionView, horizontalFloatingHeaderItemSpacingForSectionAtIndex 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,horizontalFloatingHeaderColumnSpacingForSectionAtIndex section: Int) -> CGFloat

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

##Requirements

  • iOS 8.3
  • Xcode 7.1 or later (Uses Swift 2.1 syntax)

Author

Diego Cruz, [email protected]

License

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

horizontalfloatingheaderlayout's People

Contributors

cruzdiego avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.