这里我们引入了一个名为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];
这样就完成了
网友评论