Demo: https://github.com/Rochang/LCGoodDetailViewController
先看效果:
上下拉切换控制器
LCFoodDetailViewController
使用方法:
// 继承LCFoodDetailViewController
@interface ViewController : LCFoodDetailViewController
// 添加上, 下部分控制器
- (void)addTwoChildViewControllers {
FirstViewController *firstVc = [[FirstViewController alloc] init];
[self addChildViewController:firstVc];
CustomTitleScrollViewController *secondVc = [[CustomTitleScrollViewController alloc] init];
[self addChildViewController:secondVc];
}
/*
提示:不要求上下部分控制器是UIScrollview的子类,LCFoodDetailViewController内部做了处理
if ([childFirstView isKindOfClass:[UIScrollView class]]) {
[self addMJRefreshForFirstView:(UIScrollView *)childFirstView];
[self.bgScrollView addSubview:childFirstView];
} else {
[self.bgScrollView addSubview:self.topScrollView];
[self.topScrollView addSubview:childFirstView];
[self addMJRefreshForFirstView:self.topScrollView];
}
if ([childSecondView isKindOfClass:[UIScrollView class]]) {
[self addMJRefreshForsecondView:(UIScrollView *)childSecondView];
[self.bgScrollView addSubview:childSecondView];
} else {
[self.bgScrollView addSubview:self.bottomScrollView];
[self.bottomScrollView addSubview:childSecondView];
[self addMJRefreshForsecondView:self.bottomScrollView];
}
*/
标题切换控制器LCTitleScrollViewController
使用方法:
// 继承LCTitleScrollViewController
@interface CustomTitleScrollViewController : LCTitleScrollViewController
// 重写方法
- (void)setupChildViewControllers {
UIViewController *firstVc = [[UIViewController alloc] init];
firstVc.title = @"first";
firstVc.view.backgroundColor = [UIColor grayColor];
[self addChildViewController:firstVc];
UIViewController *secondVc = [[UIViewController alloc] init];
secondVc.title = @"second";
secondVc.view.backgroundColor = [UIColor darkGrayColor];
[self addChildViewController:secondVc];
UIViewController *thirdVc = [[UIViewController alloc] init];
thirdVc.title = @"third";
thirdVc.view.backgroundColor = [UIColor lightGrayColor];
[self addChildViewController:thirdVc];
UIViewController *forthVc = [[UIViewController alloc] init];
forthVc.title = @"fourth";
forthVc.view.backgroundColor = [UIColor orangeColor];
[self addChildViewController:forthVc];
}
/*自定义样式查看LCTitleScrollViewController.h*/
/** 重写设置titleButon属性返回titleButton的宽度 */
- (CGFloat)comfiguretitleView:(UIButton *)button buttonCounts:(NSUInteger)count superViewWidth:(CGFloat)width;
/** 重写设置underLine属性的,返回underLine的宽度 */
- (CGFloat)comfigureUnderLine:(UIView *)underLine titltButton:(UIButton *)button;
/** 重写监听titleButton点击 */
- (void)titleButtonDidClick:(UIButton *)button index:(NSUInteger)index;
/** 代码设置选择button的index */
- (void)setIndexForTitleScrollViewController:(NSInteger)index animate:(BOOL)animate;
/** 获取当前显示Vc的index*/
- (NSInteger)indexforTitleScrollViewController;