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()
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()
相关文章推荐
- swift下加载XIB的方法
- 《The Swift Programming Language》中文版
- Swift 编程中的尾递归和蹦床【译】
- swift基础之协议
- [swift学习之十四]计算属性和存储属性
- Swift-错误处理(Error Handling)(十六)
- swift学习笔记之可选值和隐式可选解析
- swift学习笔记之setter和getter方法
- swift学习笔记之自动引用计数
- swift学习笔记之运算符重载
- swift学习笔记之拓展和协议
- swift学习笔记之泛型
- swift学习笔记之构造方法和析构方法
- swift学习笔记之枚举
- swift学习笔记之继承
- swift学习笔记之类和对象
- iOS Swift xib 动态桥接工具
- Swift专题讲解二十二——泛型
- swift闭包简洁到变态
- SWIFT中的repeat...while