這里我們引入了一個名為SCNavTabBar的第三方
接下來就十分的簡單了
//頭文件
#import "SCNavTabBarController.h"
下面就是viewdidload的實現代碼
UIViewController *oneViewController = [[UIViewController alloc] init];
oneViewController.title = @"新聞";
//? ? UIView *v = [[UIView alloc]initWithFrame:CGRectMake(10, 10, 100, 100)];
//
//
//? ? [oneViewController.view addSubview:v];
oneViewController.view.backgroundColor = [UIColor brownColor];
UIViewController *twoViewController = [[UIViewController alloc] init];
twoViewController.title = @"體育";
twoViewController.view.backgroundColor = [UIColor purpleColor];
UIViewController *threeViewController = [[UIViewController alloc] init];
threeViewController.title = @"娛樂八卦";
threeViewController.view.backgroundColor = [UIColor orangeColor];
UIViewController *fourViewController = [[UIViewController alloc] init];
fourViewController.title = @"天府之國";
fourViewController.view.backgroundColor = [UIColor magentaColor];
UIViewController *fiveViewController = [[UIViewController alloc] init];
fiveViewController.title = @"四川省";
fiveViewController.view.backgroundColor = [UIColor yellowColor];
UIViewController *sixViewController = [[UIViewController alloc] init];
sixViewController.title = @"政治";
sixViewController.view.backgroundColor = [UIColor cyanColor];
UIViewController *sevenViewController = [[UIViewController alloc] init];
sevenViewController.title = @"國際新聞";
sevenViewController.view.backgroundColor = [UIColor blueColor];
UIViewController *eightViewController = [[UIViewController alloc] init];
eightViewController.title = @"自媒體";
eightViewController.view.backgroundColor = [UIColor greenColor];
UIViewController *ninghtViewController = [[UIViewController alloc] init];
ninghtViewController.title = @"科技";
ninghtViewController.view.backgroundColor = [UIColor redColor];
SCNavTabBarController *navTabBarController = [[SCNavTabBarController alloc] init];
navTabBarController.subViewControllers = @[oneViewController, twoViewController, threeViewController, fourViewController, fiveViewController, sixViewController, sevenViewController, eightViewController, ninghtViewController];
navTabBarController.showArrowButton = YES;
[navTabBarController addParentController:self];
[self.navigationController setNavigationBarHidden:NO animated:YES];
這樣就完成了