Latest 0.1.0
Homepage https://github.com/FQuen/StretchyHeaderViewController
License MIT
Platforms ios 11.0
Authors

View controller with a customizable stretchy header in swift.

UIViewController containing a UIScrollView/UITableView/UICollectionView with a stretchy header. The header has a nice parallax effect and the text fades away as the header reaches its minimum size. The header is customizable.

Customizable features

  • [x] Header title
  • [x] Header subtitle
  • [x] Header image
  • [x] Minimum header height
  • [x] Maximum header height
  • [x] Tint color (title and subtitle color)
  • [x] Title font
  • [x] Text shadow color
  • [x] Text shadow offset
  • [x] Text shadow radius
  • [x] Text shadow opacity
  • [x] ScrollView (can be standard UIScrollView, UITableView or UICollectionView)
  • [x] Collapsing animation speed
  • [x] Expanding animation speed

Other features

  • [x] "progress" variable returns a value between 0 and 1 depending on header progress between its min and max value.
  • [x] expandHeader function to expand the header to its maximum height with specified animation speed.
  • [x] collapseHeader function to collapse the header to its minimum height with specified animation speed.

Requirements

  • iOS 11.0+
  • Xcode 9

Installation

CocoaPods

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

platform :ios, '11.0'
use_frameworks!
pod 'StretchyHeaderViewController'

Manually

  1. Download and drop StretchyHeaderViewController.swift in your project.
  2. Congratulations!

Usage example

let stretchyHeaderViewController = StretchyHeaderViewController()
stretchyHeaderViewController.scrollView = myTableView
stretchyHeaderViewController.headerTitle = myAwesomeTitle
stretchyHeaderViewController.headerSubtitle = myAwesomeSubtitle
stretchyHeaderViewController.minHeaderHeight = 20
stretchyHeaderViewController.maxHeaderHeight = 300
stretchyHeaderViewController.image = myImage
self.present(stretchyHeaderViewController, animated: true, completion: nil)

and in the UIScrollView/UITableView/UICollectionView UIScrollViewDelegate :

func scrollViewDidScroll(_ scrollView: UIScrollView) {
    stretchyHeaderViewController.updateHeaderView()
}

TODO

  • Unit testing
  • Add option to get header image with an URL
  • Any suggestion…

Meta

Frederic Quenneville
Distributed under the MIT license. See LICENSE for more information.

Latest podspec

{
    "name": "StretchyHeaderViewController",
    "version": "0.1.0",
    "summary": "View controller with a customizable stretchy header in swift.",
    "description": "Customizable features:n    - Header titlen    - Header subtitlen    - Header imagen    - Minimum header heightn    - Maximum header heightn    - Tint color (title and subtitle color)n    - Title fontn    - Subtitle fontn    - Text shadow colorn    - Text shadow offsetn    - Text shadow radiusn    - Text shadow opacityn    - ScrollView (can be standard UIScrollView, UITableView or UICollectionView)n    - Collapsing animation speedn    - Expanding animation speednnOther features:n    - "progress" variable returns a value between 0 and 1 depending on header progress between its min and max value.n    - expandHeader function to expand the header to its maximum height with specified animation speed.n    - collapseHeader function to collapse the header to its minimum height with specified animation speed.nnUsage:n    1. Delcare StretchyHeaderViewControllern    2. Customize its propertiesn    3. Assign a UIScrollView, UITableView or UICollectionView to "scrollView" variablen    4. Call updateHeader() function within viewDidScroll() of the presented scroll/table/collection view delegate.",
    "homepage": "https://github.com/FQuen/StretchyHeaderViewController",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Frederic Quenneville": "[email protected]"
    },
    "source": {
        "git": "https://github.com/FQuen/StretchyHeaderViewController.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "11.0"
    },
    "source_files": "StretchyHeaderViewController/*",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This