Giter VIP home page Giter VIP logo

olsdynamicheaderviewcontroller's Introduction

OLSDynamicHeaderViewController for iOS (v1.0)

This is an easy to integrate view controller that allows a UIScrollView or any of their widely used subclasses (such as UITableView and UICollectionView) to have a header view that can be animated along with scrolling.

Here an example:

Installation

OLSDynamicHeaderViewController is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "OLSDynamicHeaderViewController"

Setup

On your ViewController:

  • Make your UIViewController to inherit either one of the helpers OLSDynamicHeaderTableViewController or OLSDynamicHeaderCollectionViewController
class MyViewController: OLSDynamicHeaderTableViewController {

    // MARK - OLSDynamicHeaderViewControllerProtocol
    override func headerViewInstance() -> OLSDynamicHeaderView {
        ...
    }
    
    // ... (View Controller lifecycle and logic)
    
  • On headerViewInstance() return an instance of OLSDynamicHeaderView subclass. This class is a basic UIView subclass that conforms the protocol that will help you with the animation part =D.

Now... for your header:

  • Create a subclasss of OLSDynamicHeaderView, and implement the protocol:
class MyDynamicHeader: OLSDynamicHeaderView {

    func maxHeight() -> CGFloat { ... }

    func minHeight() -> CGFloat { ... }

    func resize(withProgress progress: CGFloat) { ... }

    func overflow(withPoints points: CGFloat)  { ... }
}
  • maxHeight returns the maximum height allowed for this view.
  • minHeight returns the minimum height allowed for this view.
  • resize(withProgress) will be called when the user scrolls and your header needs to animate. progress goes from 0 to 1, 0 min height reached, 1 max height reached.
  • overflow(withPoints) will be called when the user scrolls further the max height. points goes from 0 to N.

Note

  • The project includes a basic sample code you can use as a guidence to integrate the component in your app.
  • The project provides helper subclasses for tableView and collectionView, and the example above takes advantage of those classes. But you can go a step under and inherit from OLSDynamicHeaderViewController and move from there to have additional control.
  • If you have questions, improvements, ideas or just comments, see to the links below!

Author

Omar Hagopian, Antihero @OrangeLoops

Contact:

📨Mail | 🐥Twitter

License

OLSDynamicHeaderViewController is under the MIT license. See the LICENSE file for more info!

olsdynamicheaderviewcontroller's People

Contributors

clackmac avatar

Stargazers

 avatar

Watchers

 avatar  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.