Coder Social home page Coder Social logo

wmpagecontroller's Introduction

WMPageController 中文介绍

Platform License CocoaPods Version

An easy solution to page controllers like NetEase News

Overview


Swift Version

Click here: https://github.com/wangmchn/WMPageController-Swift

Basic use

  1. Drag files in red frame to your project.

  1. Create an controller extends from WMPageController.There are two ways to init the WMPageController:

Init with Classes

Use the following constructor to init the controller:

- (instancetype)initWithViewControllerClasses:(NSArray *)classes 
                               andTheirTitles:(NSArray *)titles;

Here are two important porperties:

classes :contains the classes of child view controllers, just like [UITableViewController class];
titles  :Each View controller's title to show in the menu view at the top of the view;

Use datasource

The usage is very familiar to UITableView, these are the methods need to implement:

- (NSInteger)numbersOfChildControllersInPageController:(WMPageController *)pageController;

- (__kindof UIViewController *)pageController:(WMPageController *)pageController viewControllerAtIndex:(NSInteger)index;

- (NSString *)pageController:(WMPageController *)pageController titleAtIndex:(NSInteger)index;

Just implement these three datasource methods in YOUR WMPageController after initialize it.

More

To have a custom page controller,please set the properties in WMPageController ,They are: titleSize, titleColor, menuHeight, pageAnimatable, menuBGColor, menuItemWidth,and also itemsWidths.

ViewFrame

It's easy for you to customize your controller as following, just set viewFrame and done.
See ViewFrameDemo for more information.

Use Storyboard / xib

1.If you init the WMPageController with child controller's class,override the -init method in WMPageController's childViewController, For example:

- (instancetype)init {
    return [self initWithNibName:@"xxxViewController" bundle:nil];
}

2.If you are using datasource, Just implement -pageController:viewControllerAtIndex: as following:

- (UIViewController *)pageController:(WMPageController *)pageController viewControllerAtIndex:(NSInteger)index {
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"WMViewController"];
    return vc;
}

Styles

There are 4 styles to choose, They are WMMenuViewStyleDefault, WMMenuViewStyleLine, WMMenuViewStyleFoold, WMMenuViewStyleFooldHollow;

You can easily change style by setting xxxPageController.style = WMMenuViewStyleLine.
If you want menuView to show on the navigation bar, set .showOnNavigationBar = YES;

Using CocoaPods

pod 'WMPageController'

Note

You can put every controller in WMPageController,But if you want have a UICollectionViewController in, please have an attention to UICollectionViewController's init method.
You should override the - init to give UICollectionViewController a UICollectionViewLayout. Here is an example:

- (instancetype)init {
    // init layout here...
    self = [self initWithCollectionViewLayout:layout];
    if (self) {
        // insert code here...
    }
    return self;
}

License

This project is under MIT License. See LICENSE file for more information.

wmpagecontroller's People

Contributors

chengxianghe avatar chinsyo avatar codwam avatar edwardbx avatar jeeliu avatar litt1e-p avatar sinofake avatar wangmchn 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.