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內(nèi)部做了處理
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*/
/** 重寫設(shè)置titleButon屬性返回titleButton的寬度 */
- (CGFloat)comfiguretitleView:(UIButton *)button buttonCounts:(NSUInteger)count superViewWidth:(CGFloat)width;
/** 重寫設(shè)置underLine屬性的,返回underLine的寬度 */
- (CGFloat)comfigureUnderLine:(UIView *)underLine titltButton:(UIButton *)button;
/** 重寫監(jiān)聽titleButton點擊 */
- (void)titleButtonDidClick:(UIButton *)button index:(NSUInteger)index;
/** 代碼設(shè)置選擇button的index */
- (void)setIndexForTitleScrollViewController:(NSInteger)index animate:(BOOL)animate;
/** 獲取當前顯示Vc的index*/
- (NSInteger)indexforTitleScrollViewController;