Coder Social home page Coder Social logo

carabina / nkjpagerviewcontroller Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nakajijapan/nkjpagerviewcontroller

0.0 1.0 0.0 4.41 MB

NKJPagerViewController is like a FragmentsTabsPager, which is in Android. It contains an endlessly scrollable UIScrollView.

License: MIT License

Objective-C 96.77% Ruby 3.23%

nkjpagerviewcontroller's Introduction

NKJPagerViewController

Gitter

NKJPagerViewController is like a FragmentsTabsPager, which is in Android. It contains an endlessly scrollable UIScrollView.

This viewController inspired ICViewPager. The biggest of difference is to infinitely swipe page.

Requirements

NKJPagerViewController higher requires Xcode 6, targeting either iOS 7.1 and above, or Mac OS 10.10 OS X Yosemite and above.

Installation

CocoaPods

pod "NKJPagerViewController"

Usage

Implement as subclass of NKJPagerViewController and imprement dataSource and delegate methods in the subclass.

- (void)viewDidLoad
{
    self.dataSource = self;
    self.delegate = self;

    [super viewDidLoad];
}

NKJPagerViewDataSource

Decide number of tabs.

- (NSUInteger)numberOfTabView
{
    return 10;
}

Decide width for each tab.

- (NSInteger)widthOfTabView
{
    return 160;
}

Setting a view design for each tab.

- (UIView *)viewPager:(NKJPagerViewController *)viewPager viewForTabAtIndex:(NSUInteger)index
{
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 160, 44)];
    label.backgroundColor = [UIColor grayColor];
    label.font = [UIFont systemFontOfSize:12.0];
    label.text = [NSString stringWithFormat:@"Tab #%lu", index * 10];
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [UIColor blackColor];

    return label;
}

Setting a view controller for each tab.

- (UIViewController *)viewPager:(NKJPagerViewController *)viewPager contentViewControllerForTabAtIndex:(NSUInteger)index
{
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    ContentViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"ContentViewController"];
    vc.textLabel = [NSString stringWithFormat:@"Content View #%lu", index];
    return vc;
}

NKJPagerViewDelegate

This method is option.

- (void)viewPager:(NKJPagerViewController *)viewPager didSwitchAtIndex:(NSInteger)index withTabs:(NSArray *)tabs
{
    // do something
}

Author

@nakajijapan

License

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

nkjpagerviewcontroller's People

Contributors

gitter-badger avatar nakajijapan avatar

Watchers

 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.