1、viewController都有nav
2、nav.root=TabBarController
各个viewController 的区别
第一种 每个viewControll对应一个navigationcontroller
let firstVC=IndexViewController();
let nav1=UINavigationController(rootViewController:firstVC);
let image1=UIImage(named:"a");
nav1.tabBarItem=UITabBarItem(title:"aaa",image:image1,tag:1);
let secondVC=IndexViewController();
let nav2=UINavigationController(rootViewController:secondVC);
let image2=UIImage(named:"b");
nav2.tabBarItem=UITabBarItem(title:"bbb",image:image2,tag:2);
let thirdVC=IndexViewController();
let nav3=UINavigationController(rootViewController:thirdVC);
let image3=UIImage(named:"c");
nav3.tabBarItem=UITabBarItem(title:"ccc",image:image3,tag:3);
let navArr=[nav1,nav2,nav3];
let tabBarController=UITabBarController();
tabBarController.viewControllers=navArr;
root = tabBarController
每个viewcontroller可以修改自己的nav title
第二种 nav的root直接等于tabbarcontroller
let vc1 = IndexViewController()
let vc2 = IndexViewController()
let vc3 = IndexViewController()
let item1:UITabBarItem = UITabBarItem(title: "a", image: nil, tag: 1)
let item2:UITabBarItem = UITabBarItem(title: "b", image: nil, tag: 1)
let item3:UITabBarItem = UITabBarItem(title: "c", image: nil, tag: 1)
vc1.tabBarItem = item1
vc2.tabBarItem = item2
vc3.tabBarItem = item3
let tabbar = UITabBarController()
tabbar.viewControllers = [vc1,vc2,vc3]
root = UINavigationController(rootViewController:tabbar)
** viewcontroller不能可以修改自己的nav title**
来源:oschina
链接:https://my.oschina.net/u/2547410/blog/744174