继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

QLPageViewController,翻页滚动,类头条滑动,适合做新闻媒体或者订单类的页面

慕虎7371278
关注TA
已关注
手记 1125
粉丝 201
获赞 871

mport "QLPageView.h"

初始化

NSArray *vcs = @[[[TestViewController1 alloc] init],

                    [[TestViewController2 alloc] init],

                    [[TestViewController3 alloc] init],

                    [[TestViewController4 alloc] init],

                    [[TestViewController5 alloc] init],

                    [[TestViewController6 alloc] init]];    NSArray *titles = @[@"第一页", @"第二页", @"3", @"第4444444444页", @"第5页", @"第六页"];    CGFloat y = KIsiPhoneX ? 88 : 64;    //同样的页面跟换数据源的话,直接循环

    QLPageView *toolView = [[QLPageView alloc] initWithFrame:CGRectMake(0, y, self.view.bounds.size.width, self.view.bounds.size.height - y) viewControllers:vcs titles:titles];

    toolView.mDelegate = self;    //下面这几个属性自由选择是赋值

    toolView.itemNormalColor = [UIColor blackColor];

    toolView.itemSelectedColor = [UIColor redColor];

    toolView.hideShadow = NO;

    toolView.selectedIndex = 3;    //这一句必须写

    [toolView showInViewController:self];

遵循代理并实现代理

#pragma mark - QLPageViewDelegate- (void)selectedPageOfIndex:(NSInteger)index{    NSLog(@"selected  %ld", index);

}

效果图

webp

image

不需要居中的话只需要把这里注释掉


webp

image

写的时候分析附图,纠正一下,既然viewWillAppear每次执行,那么肯定比在
scrollowView上面横向加多个viewController这种一次性全部加载的性能要好很多!


webp



作者:墨柒_js
链接:https://www.jianshu.com/p/7b23c068200a


打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP