Arale
A custom stretchy big head for UITableView, UICollectionView, or any UIScrollView subclasses.
A custom stretchy big header view for UITableView, UICollectionView, or any UIScrollView subclasses with refresh control support. Built for iOS 10 and later, written in Swift.
Arale, by ZulwiyozaPutra
- Compatible with
UITableView
,UICollectionView
, or anyUIScrollView
subclasses. - Data source and delegate independency: can be added to an existing view controller without interfering with your existing
delegate
ordataSource
. - No need to subclass a custom view controller or to use a custom
UICollectionViewLayout
.
Usage
To add a stretchy header to your table or collection view, you just have to do this:
import Arale
var araleHeaderView: AraleHeaderView!
...
let araleHeaderView = AraleHeaderView(minHeight: 256.0, backgroundImage: myBackgroundImage)
araleHeaderView.delegate = self
self.tableView.addSubview(self.araleHeaderView)
...
// In case you want to add an UIActivityIndicatorView
// To handle action if the AraleHeaderView has resize to maxHeight you can implement a AraleHeaderViewDelegate conformed UIViewController
araleHeaderView.delegate = self
...
// And implement headerViewDidReachMaxHeight to get event when the araleHeaderView did reach the maximum height
func headerViewDidReachMaxHeight(headerView: AraleHeaderView) {
NSLog("%@", "Start Refreshing")
headerView.activityIndicatorView.stopAnimating()
}
...
// AraleHeaderViewDelegate comes with three optional delegate method
func headerViewWillResizeFrame(headerView: AraleHeaderView)
func headerViewDidResizeFrame(headerView: AraleHeaderView)
func headerViewDidReachMaxHeight(headerView: AraleHeaderView)
...
Configuration
You can add an optional UIViewActivityIndicatorView
in your stretchy header view:
let myActivityIndicatorview = UIActivityIndicatorView(style: .white)
self.araleHeadeView.activityIndicatorView = myActivityIndicatorView
the activityIndicatorView
will not be rendered if remain nil
in case you don't need an activityIndicator.
Installation
Arale 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 "Arale"