首先在AppDelegate里写入
#pragma mark - Methods
- (void)setupViewControllers {
UIViewController *firstViewController = [[SupermarketViewController alloc] init];
UIViewController *firstNavigationController = [[UINavigationController alloc]
initWithRootViewController:firstViewController];
//实例化三个ViewController
OrderViewController *firstVC = [[OrderViewController alloc] init];
twoViewController *secondVC =[[twoViewController alloc] init];
threeViewController *thirdVC = [[threeViewController alloc] init];
JRSegmentViewController *vc = [[JRSegmentViewController alloc] init];
//显示三个按钮
[vc setTitles:@[@"全部", @"待收货", @"待评价"]];
//设置segmentBg的颜色
vc.segmentBgColor = [UIColor orangeColor];
vc.indicatorViewColor = [UIColor whiteColor];
[vc setViewControllers:@[firstVC, secondVC, thirdVC]];
UIViewController *secondViewController = vc;
UIViewController *secondNavigationController = [[UINavigationController alloc]
initWithRootViewController:secondViewController];
UIViewController *thirdViewController = [[MineViewController alloc] init];
UIViewController *thirdNavigationController = [[UINavigationController alloc]
initWithRootViewController:thirdViewController];
RDVTabBarController *tabBarController = [[RDVTabBarController alloc] init];
[tabBarController setViewControllers:@[firstNavigationController, secondNavigationController,
thirdNavigationController]];
self.viewController = tabBarController;
[self customizeTabBarForController:tabBarController];
}
之后引入一个第三方JRSegmentViewController
网友评论