WMPageController 中文介绍
An easy solution to page controllers like NetEase News
And you can easily change styles by setting `menuViewStyle` property: ```objective-c pageController.menuViewStyle = WMMenuViewStyleLine; ``` ## Swift Version Click here: https://github.com/wangmchn/WMPageController-Swift
- Now page controller has a cache policy and scroll much more fluently!
- Add
itemMarginanditemsMarginsto custom margin between each item,viewFrameto custom controller.view's frame. - Add
valuesandkeysproperties which can help pass values to childControllers throughKVC. - If items width didn't fill the screen width,
WMPageControllerwill calculate width and add gap between each item automatically; - Adjust views and frames when device's orientation changed;
- Set the property
itemsWidthsto have Different Width! Like@[@(100),@(80),@(50).....]; - Can reload data like
NetEase News.
First Drag files in red frame to your project.

Then,create an controller that extends from WMPageController.I recommend to use
- (instancetype)initWithViewControllerClasses:(NSArray *)classes
andTheirTitles:(NSArray *)titles;to init the controller.Here are two important porperties
classes :contains the classes of view controller, you can put obj in like [UITableViewController class];
titles :Each View controller's title to show in the menu view at the top of the view;
To have a custom page controller,please set the properties in WMPageController ,They are: titleSize, titleColor, menuHeight, pageAnimatable, menuBGColor, menuItemWidth,,and also rememberLocationitemsWidths.
pod 'WMPageController'
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;
}This project is under MIT License. See LICENSE file for more information.
WMPageController是一个方便形成如同网易新闻首页,控制器滑动翻页效果的控制器。(原谅我拙略的英文)
戳这里: https://github.com/wangmchn/WMPageController-Swift
- 增加了缓存机制,对加载过的控制器进行缓存,当内存过高时自动清理缓存。
- 可通过
itemMargin和itemsMargins来定制顶部标题的间距,通过viewFrame来定制子控制器的frame属性。 - 通过设置
values和keys向子控制器传值。(内部利用KVC实现) - 当标题宽度之和不足宽度时,自动计算并为顶部
item添加间隙。 - 适配横屏,当设备旋转时自动调整
frame。 - 可通过设置
itemsWidths属性来设置不同的标题宽度,例如@[@(100),@(80),@(50).....]; - 增加了
reload功能,可以像网易新闻那样重新更新标题和控制器。
然后,创建一个控制器继承自WMPageController,并使用以下方法初始化该控制器
- (instancetype)initWithViewControllerClasses:(NSArray *)classes
andTheirTitles:(NSArray *)titles;其中,Classes是要传人显示的控制器的类型,比如[UITableViewController class], titles是要显示的控制对应的标题。
如要定制WMPageController的外观,可通过设置如下属性:
titleSize, titleColor, menuHeight, pageAnimatable, menuBGColor, menuItemWidth,,以及 rememberLocationitemsWidths.
pod 'WMPageController'
如果需要传入 UICollectionViewController, 需要重写 - init 方法,来为UICollectionViewController提供一个 UICollectionViewLayout。
方式如下:
- (instancetype)init {
// init layout here...
self = [self initWithCollectionViewLayout:layout];
if (self) {
// insert code here...
}
return self;
}该项目使用 MIT 许可证,详情见 LICENSE 文件。
