Swift下同时创建UITabBarController和UINavigationControlle

来源:互联网 发布:金十数据解读 编辑:程序博客网 时间:2024/06/10 19:41

//在window上设置窗口为UITabBarController

self.window=UIWindow(frame: UIScreen.mainScreen().bounds) 

self.window!.rootViewController = UITabBarController()

self.window!.makeKeyAndVisible()

return true


//在UITabBarController的.swift文件中 创建UIViewController,并且包装成导航控制器

let SY = UIViewController()      //创建

let NV = UINavigationController(rootViewController: SY)    //包装

//设置导航栏标题

SY.navigationItem.title = "enenenn"

//设置TabBar标题

NV.tabBarItem.title = "首页"

//添加到TabBar

viewControllers=[NV]   //这行的意思是多个控制器可以以数组的形式一次添加上去

或者

addChildViewController(NV)

-------------------------------------------------------------

//设置tabBar 栏的背景颜色

self.tabBar.barTintColorUIColor.redColor()

//设置导航条背景颜色

NV.navigationBar.barTintColor = UIColor.redColor()





 






0 0
原创粉丝点击