All Projects → gskbyte → Gskstretchyheaderview

gskbyte / Gskstretchyheaderview

Licence: mit
A generic stretchy header for UITableView and UICollectionView

Programming Languages

objective c
16641 projects - #2 most used programming language
c
50402 projects - #5 most used programming language
swift
15916 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Gskstretchyheaderview

Viewanimator
ViewAnimator brings your UI to life with just one line
Stars: ✭ 6,592 (+305.91%)
Mutual labels:  uikit, uiview, uicollectionview, uitableview
Closures
Swifty closures for UIKit and Foundation
Stars: ✭ 1,720 (+5.91%)
Mutual labels:  uiview, uicollectionview, uitableview, uiscrollview
ios ui recipe showcase
iOSアプリ開発 - UI実装であると嬉しいレシピブック掲載サンプル
Stars: ✭ 54 (-96.67%)
Mutual labels:  uitableview, uicollectionview, uikit, interface-builder
Tysnapshotscroll
一句代码保存截图,将 UIScrollView UITableView UICollectionView UIWebView WKWebView 网页 保存 为 长图 查看。Save the scroll view page as an image,support UIScrollView,UITableView,UICollectionView,UIWebView,WKWebView.(Support iOS13)
Stars: ✭ 709 (-56.34%)
Mutual labels:  uicollectionview, uitableview, uiscrollview
Squaremosaiclayout
An extandable mosaic UICollectionViewLayout with a focus on extremely flexible customizations 🔶
Stars: ✭ 243 (-85.04%)
Mutual labels:  uikit, uicollectionview, uitableview
XLRefresh
iOS 下拉刷新工具
Stars: ✭ 25 (-98.46%)
Mutual labels:  uitableview, uicollectionview, uiscrollview
TinderUISamples
[ING] - TinderのようなUIを様々な実装で実現してみる
Stars: ✭ 30 (-98.15%)
Mutual labels:  uicollectionview, uikit, uiview
Pagingkit
PagingKit provides customizable menu UI. It has more flexible layout and design than the other libraries.
Stars: ✭ 1,030 (-36.58%)
Mutual labels:  uikit, uicollectionview, uitableview
Persei
Animated top menu for UITableView / UICollectionView / UIScrollView written in Swift
Stars: ✭ 3,395 (+109.05%)
Mutual labels:  uicollectionview, uitableview, uiscrollview
Wlemptystate
WLEmptyState is an iOS based component that lets you customize the view when the dataset of a UITableView or a UICollectionView is empty. We created a sample project with the WLEmptyState component to show how you can use it.
Stars: ✭ 305 (-81.22%)
Mutual labels:  uikit, uicollectionview, uitableview
Baraba
Make your UIScrollView scroll automatically when user is looking 👀 by tracking face using ARKit and AVFoundation
Stars: ✭ 268 (-83.5%)
Mutual labels:  uicollectionview, uitableview, uiscrollview
Mylinearlayout
MyLayout is a powerful iOS UI framework implemented by Objective-C. It integrates the functions with Android Layout,iOS AutoLayout,SizeClass, HTML CSS float and flexbox and bootstrap. So you can use LinearLayout,RelativeLayout,FrameLayout,TableLayout,FlowLayout,FloatLayout,PathLayout,GridLayout,LayoutSizeClass to build your App 自动布局 UIView UITab…
Stars: ✭ 4,152 (+155.67%)
Mutual labels:  uicollectionview, uitableview, uiscrollview
Owl
A declarative type-safe framework for building fast and flexible lists with UITableViews & UICollectionViews
Stars: ✭ 423 (-73.95%)
Mutual labels:  uikit, uicollectionview, uitableview
Basecomponents
BaseComponents aims to provide easily reusable and understandable components to increase productivity with UIKit and Foundation APIs
Stars: ✭ 92 (-94.33%)
Mutual labels:  uikit, uicollectionview, uitableview
Gltablecollectionview
Netflix and App Store like UITableView with UICollectionView, written in pure Swift 4.2
Stars: ✭ 709 (-56.34%)
Mutual labels:  uicollectionview, uitableview
Swipecellkit
A swipeable UITableViewCell or UICollectionViewCell with support for:
Stars: ✭ 5,745 (+253.76%)
Mutual labels:  uikit, uitableview
Skeletonview
☠️ An elegant way to show users that something is happening and also prepare them to which contents they are awaiting
Stars: ✭ 10,804 (+565.27%)
Mutual labels:  uicollectionview, uitableview
Ttsegmentedcontrol
An elegant, animated and customizable segmented control for iOS created by Tapptitude
Stars: ✭ 471 (-71%)
Mutual labels:  uikit, interface-builder
Color Picker For Ios
Colorful: iOS color picker built with Swift.
Stars: ✭ 709 (-56.34%)
Mutual labels:  uikit, interface-builder
Flix
iOS reusable form library in Swift.
Stars: ✭ 725 (-55.36%)
Mutual labels:  uicollectionview, uitableview

GSKStretchyHeaderView, by gskbyte

License Platform Carthage compatible Version

CI Status Coverage

Example 1 Example 2 Example 3 Example 4 Example 5

GSKStretchyHeaderView is an implementation of the stretchy header paradigm as seen on many apps, like Twitter, Spotify or airbnb. It's designed in order to accomplish the following requirements:

  • Compatibility with UITableView and UICollectionView
  • Data source and delegate independency: can be added to an existing view controller withouth interfering with your existing delegate or dataSource
  • Provide support for frame layout, auto layout and Interface Builder .xib files
  • No need to subclass a custom view controller or to use a custom UICollectionViewLayout
  • Simple usage: just implement your own subclass and add it to your UIScrollView subclass
  • Two expansion modes: the header view can grow only when the top of the scroll view is reached, or as soon as the user scrolls down.

If you are using this library in your project, I would be more than glad to know about it!

Usage

To add a stretchy header to your table or collection view, you just have to do this:

var stretchyHeader: GSKStretchyHeaderViewSubclass!

...

func viewDidLoad() {
    super.viewDidLoad()
    let headerSize = CGSize(width: self.tableView.frame.size.width, 
                            height: 200) // 200 will be the default height
    self.stretchyHeader = GSKStretchyHeaderViewSubclass(frame: CGRect(x: 0, y: 0,
                                                                      width: headerSize.width, 
                                                                      height: headerSize.height))
    self.stretchyHeader.delegate = self // this is completely optional
    self.tableView.addSubview(self.stretchyHeader)
}

or

func viewDidLoad() {
    super.viewDidLoad()
    let nibViews = Bundle.main.loadNibNamed("GSKTabsStretchyHeaderView", owner: self, options: nil)
    self.stretchyHeaderView = nibViews.firstObject
    self.tableView.addSubview(self.stretchyHeaderView)
}

Compatibility with iOS 11 and the iPhone X

After the changes introduced in iOS 11, some issues have appeared with the safe area adjustments to scroll views. To avoid glitches and strange behaviours, just do the following when you set up your header view:

if #available(iOS 11.0, *) {
    self.tableView.contentInsetAdjustmentBehavior = .never
}

For the time being, we haven't found a better way to deal with the contentInset adjustment, so the support for the iPhone X and the safeAreaInsets is not there yet. This may require a major refactor of the header view and a major release. For more information, see this issue and this PR (#68).

Configuration

You can change multiple parameters in your stretchy header view:

// you can change wether it expands at the top or as soon as you scroll down
headerView.expansionMode = .immediate

// You can change the minimum and maximum content heights
headerView.minimumContentHeight = 64 // you can replace the navigation bar with a stretchy header view
headerView.maximumContentHeight = 280

// You can specify if the content expands when the table view bounces, and if it shrinks if contentView.height < maximumContentHeight. This is specially convenient if you use auto layout inside the stretchy header view
headerView.contentShrinks = true
headerView.contentExpands = false // useful if you want to display the refreshControl below the header view

// You can specify wether the content view sticks to the top or the bottom of the header view if one of the previous properties is set to `false`
// In this case, when the user bounces the scrollView, the content will keep its height and will stick to the bottom of the header view
headerView.contentAnchor = .bottom

Creating your stretchy header

There are two ways to create your own stretchy header:

  • Create a stretchy header subclass and add subviews to its contentView. You can layout its subviews manipulating their frames or using Auto Layout (also works with GranadaLayout :trollface:).
  • Create an Interface Builder file and map it to your GSKStretchyHeaderView subclass. Subviews added to the stretchy header will be automatically moved to the content view, keeping their constraints. Remember to set the properties maximumContentHeight and minimumContentHeight in the attributes inspector (fourth tab on the right panel in Interface Builder).

To modify the behaviour and layout of your stretchy header, just override the method -didChangeStretchFactor: in your subclass, where you can adjust it by using the stretchFactor. To get a more detailed description of the properties, please have a look at the source code. There are also a few usage examples in the example project. You can also take them as a reference for your own stretchy headers.

Example project

To run the example project, clone the repo and open the workspace file GSKStretchyHeaderView.xcworkspace.

You can also use pod try GSKStretchyHeaderView.

Installation

GSKStretchyHeaderView is available through CocoaPods. To install it, simply add the following line to your Podfile, you can check the Example Podfile to see how it looks like:

pod "GSKStretchyHeaderView"

GSKStretchyHeaderView is also available through Carthage. To install it, just add this line to your `Cartfile:

github "gskbyte/GSKStretchyHeaderView"

and run

carthage update GSKStretchyHeaderView

Author

Jose Alcalá Correa

Contributions

Contributions are more than welcome! If you find a solution for a bug or have an improvement, don't hesitate to open a pull request!

License

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

If your app uses GSKStretchyHeaderView, I'd be glad if you ping me via Twitter or via email.

Changelog

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].