您的位置:首页 > 移动开发 > Swift

Swift下同时创建UITabBarController和UINavigationControlle

2016-05-30 14:44 393 查看
//在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.barTintColor = 
UIColor.redColor()

//设置导航条背景颜色

NV.navigationBar.barTintColor = UIColor.redColor()

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: