代码库> 分段选择> SGPageView
SGPageView
关注
上传者:Hanymore 分类:分段选择(Segment)
查看次数:2011 下载次数:445
上传时间:2017-04-24 大小:1 KB
建议去 GitHub 下载最新 Demo:https://github.com/kingsic/SGPageView.git

SGPageView 可根据内容自动选取是静止状态,还是滚动状态

使用方法:

* 将项目中 SGPageView 文件夹拖入工程

* 导入 #import "SGPageView.h" 的头文件

创建滚动内容视图
/// 创建子控制器

ChildVCOne *oneVC = [[ChildVCOne alloc] init];

ChildVCTwo *twoVC = [[ChildVCTwo alloc] init];

ChildVCThree *threeVC = [[ChildVCThree alloc] init];

ChildVCFour *fourVC = [[ChildVCFour alloc] init];

NSArray *childArr = @[oneVC, twoVC, threeVC, fourVC];

/// pageContentView

CGFloat contentViewHeight = self.view.frame.size.height - 108;

self.pageContentView = [[SGPageContentView alloc] initWithFrame:CGRectMake(0, 108, self.view.frame.size.width, contentViewHeight) parentVC:self childVCs:childArr];

_pageContentView.delegatePageContentView = self;

[self.view addSubview:_pageContentView];

滚动内容视图代理方法
- (void)SGPageContentView:(SGPageContentView *)SGPageContentView progress:(CGFloat)progress originalIndex:(NSInteger)originalIndex targetIndex:(NSInteger)targetIndex {

[self.pageTitleView setPageTitleViewWithProgress:progress originalIndex:originalIndex targetIndex:targetIndex];

}

创建滚动标题视图
/// 子标题数组

NSArray *titleArr = @[@"精选", @"电影", @"电视剧", @"综艺"];

/// pageTitleView

self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, 64, self.view.frame.size.width, 44) delegate:self titleNames:titleArr];

_pageTitleView.selectedIndex = 1;

[self.view addSubview:_pageTitleView];

滚动标题视图代理方法
- (void)SGPageTitleView:(SGPageTitleView *)SGPageTitleView selectedIndex:(NSInteger)selectedIndex {

[self.pageContentView setPageCententViewCurrentIndex:selectedIndex];

}
收藏
我来说两句
发表评论
您还没有登录!请登录注册
所有评论(0
提示
sina weixin mail 回到顶部