GithubHelp home page GithubHelp logo

rakutou / abfullscrollviewcontroller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andresbrun/abfullscrollviewcontroller

0.0 2.0 0.0 4.92 MB

Behaviour objects the provides the behaviour o hiding the header view as the user scrolls. Similar to Facebook, Safari, Twitter...

License: MIT License

Objective-C 93.12% Ruby 6.88%

abfullscrollviewcontroller's Introduction

alt tag

License MIT Build Status Build Platform Build Version

Component that provide the behavior of hidding a header view while the user makes scroll. It is inspiring in Facebook table scroll style. For sake of simplicity this component follows Behavioral Object Pattern Objc.io.

Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like ABMFullScrollBehavior in your projects.

Podfile

pod "ABMFullScrollBehavior"

Manual Installation

If you don't want to use cocoapods you just need to copy ABMFullScrollBehavior folder in your project.

Configuration

In order to apply this behaviour to your scroll based view you just need to follow next steps:

  • Create a new Object in your ViewController using the .xib.

alt tag

  • Change the class to ABMFullScrollBehavior

alt tag

  • Connect the different IBOutlets:

    • delegate
    • headerView
    • scrollView
  • This object have a couple of IBInspectable properties that you can set from the storyboard:

    • Imantate in case you want to avoid the user leave the header in a non-end state.
    • MinVisibleHeightHeader to define how much header view height will remain visible.

alt tag

  • And that is! You got your scroll hiding the header when the user makes scroll!

I want to use my scroll base element delegate

Most likely you will want your UITableView reacts when the user press a cell and for that you need to use its delegate for instance. But I need it too to know when the user is doing scroll. Fine, let's solve this!

Inside of the component there is another class called ABMMultiplexerProxyBehavior. That is used for connect one delegate and forward every call to every target we connect to it. So the steps would be:

  • Create a ABMMultiplexerProxyBehavior object in our ViewController using the storyboard or .xib editor.
  • Instead of connecting our scroll base element delegate to ABMFullScrollBehavior object we should connect it to this new object.
  • ABMMultiplexerProxyBehavior has and IBOutlet called targets. This is a IBOutletCollection so we can connect our ABMFullScrollBehavior object and the ViewController as well.

I want to customize the animation

You can provide a delegate for ABMFullScrollBehavior and implement it like the example:

- (void)scroll:(UIScrollView *)scroll animationForHeaderView:(UIView *)view percent:(CGFloat)percent {
    [self.headerContainerView setAlpha:percent];
    
    CGFloat transform = MIN(percent+0.5, 1);
    [self.headerContainerView setTransform:CGAffineTransformMakeScale(transform, transform)];
}

Architecture

Let's do an small summarize of how is design all the connections between the different objects.

Without ABMMultiplexerProxyBehavior

alt tag

With ABMMultiplexerProxyBehavior

alt tag

Features

  • This components supports Size classes and Autolayout.
  • Also supports Navigation Item.
  • It works with any UI element that inherate from UIScrollView class.
    • UICollectionView
    • UITableView
    • UIScrollView
  • Everthing is configured just using storyboard of .xib editor. That make more encapsulate this code and it is painless to integrate and modify.

Examples

alt tag

License

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

abfullscrollviewcontroller's People

Contributors

andresbrun avatar bitdeli-chef 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.