Skip to content
/ Arale Public
forked from supercomputra/Arale

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.

License

Notifications You must be signed in to change notification settings

carabina/Arale

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License Platform Version

Arale

A custom stretchy big head for UITableView, UICollectionView, or any UIScrollView subclasses.

Demo

Example 1

Arale, by ZulwiyozaPutra

  • Compatible with UITableView, UICollectionView, or any UIScrollView subclasses.
  • Data source and delegate independency: can be added to an existing view controller withouth interfering with your existing delegate or dataSource
  • 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

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:

import Arale

var araleHeaderView: HeaderView!

...

func viewDidLoad() {
  super.viewDidLoad()
  let araleHeaderView = HeaderView(minHeight: 256.0)
  araleHeaderView.delegate = self
  araleHeaderView.dataSource = self
  self.araleHeaderView.delegate = self
  self.araleHeaderView.dataSource = self
  self.tableView.addSubview(self.araleHeaderView)
}

...

// You need to conform your ViewController to HeaderViewDataSource
// observableScrollViewForHeaderView will return any UIScrollView children instance to be tracked by the HeaderView

func observableScrollViewForHeaderView() -> UIScrollView {
  guard let tableView = self.tableView else {
    fatalError()
  }
        
  return tableView
}

...

// In case you want to add a refreshControl
// To handle action if the HeaderView has resize to maxHeight you can use HeaderViewDelegate

func headerViewWillStartRefreshing() {
  // If you have a refreshControl in the HeaderView then it will start refreshing for you
  print("Handle Your Refreshing Action Here")
}

Configuration

You can change multiple parameters in your stretchy header view:

// you can set the margin between the big head and your content to 0, the default is 16
araleHeaderView.bottomMargin = 0

// You can change the minimum and maximum content heights
araleHeaderView.minHeight = 64
araleHeaderView.maxHeight = 280

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"

Author

Zulwiyoza Putra

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

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

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

About

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.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 67.5%
  • Ruby 27.0%
  • Objective-C 5.5%