Giter Site home page Giter Site logo

mxsegmentedpager's Introduction

MXSegmentedPager

CI Status Version Carthage compatible License Platform Dependency Status

MXSegmentedPager combines MXPagerView with HMSegmentedControl to control the page selection. The integration of MXParallaxHeader allows you to add an parallax header on top while keeping a reliable scrolling effect.

Simple view Parallax view
Demo Demo

Highlight

  • HMSegmentedControl is a very customizable control.
  • MXParallaxHeader supports any kind of view with different modes.
  • MXPagerView lazily loads pages and supports reusable page registration.
  • Reliable vertical scroll with any view hierarchy.
  • Can load view-controller from storyboard using a custom segue.
  • Fully documented.

Usage

  • MXSegmentedPager calls data source methods to load pages.
#pragma mark <MXSegmentedPagerDataSource>

// Asks the data source to return the number of pages in the segmented pager.
- (NSInteger)numberOfPagesInSegmentedPager:(MXSegmentedPager *)segmentedPager {
    return 10;
}

// Asks the data source for a title realted to a particular page of the segmented pager.
- (NSString *)segmentedPager:(MXSegmentedPager *)segmentedPager titleForSectionAtIndex:(NSInteger)index {
    return [NSString stringWithFormat:@"Page %li", (long) index];
}

// Asks the data source for a view to insert in a particular page of the pager.
- (UIView *)segmentedPager:(MXSegmentedPager *)segmentedPager viewForPageAtIndex:(NSInteger)index {
    
    UILabel *label = [UILabel new];
    label.text = [NSString stringWithFormat:@"Page #%i", index];
    label.textAlignment = NSTextAlignmentCenter;;

    return label;
}
  • Adding a parallax header to a MXSegmentedPager is straightforward, e.g:
UIImageView *headerView = [UIImageView new];
headerView.image = [UIImage imageNamed:@"success-baby"];
headerView.contentMode = UIViewContentModeScaleAspectFill;
   
MXSegmentedPager *segmentedPager = [MXSegmentedPager new]; 
segmentedPager.parallaxHeader.view = headerView;
segmentedPager.parallaxHeader.height = 150;
segmentedPager.parallaxHeader.mode = MXParallaxHeaderModeFill;
segmentedPager.parallaxHeader.minimumHeight = 20;

Examples

If you want to try it, simply run:

pod try MXSegmentedPager

Or clone the repo and run pod install from the Example directory first.

  • See MXSimpleViewController for a standard implementation.
  • See MXParallaxViewController to implement a pager with a parallax header.
  • See MXExampleViewController for a MXSegmentedPagerController subclass example.

This repo also provides a Swift example project, see Example-Swift.

Installation

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

pod 'MXSegmentedPager'

Documentation

Documentation is available through CocoaDocs.

Author

Maxime Epain

Twitter

License

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

mxsegmentedpager's People

Contributors

maxep avatar cerupcat avatar drjid avatar mdagostino avatar bitdeli-chef avatar riosc avatar bigluck avatar jiangmingz avatar

Watchers

James Cloos 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.