//创建window
self.window = UIWindow(frame:UIScreen.mainScreen().bouns)
//设置根VC
self.window!.rootViewController = ViewController()
//创建一个btn
var btn = UIButton (frame:CGRect(x: 100, y: 100, width: 100, height: 100))
// 设置背景颜色
btn.backgroundColor = UIColor.yellowColor();
// 将添加到我们的vc上
self.window!.rootViewController!.view.addSubview(btn)
self.window!.makeKeyAndVisible()
//创建window
self.window = UIWindow(frame:UIScreen.mainScreen().bounds)
//创建VC
let vc = ViewController()
let oneVc = OnrViewController()
let two = TwoViewController()
let three = ThreeViewController()
let four = FourViewController()
//设置背景颜色
vc.view.backgroundColor = UIColor.redColor()
vc.title = "SwiftDemo"
vc.tabBarItem.title = vc.title
oneVc.title = "2"
oneVc.view.backgroundColor = UIColor.greenColor()
oneVc.tabBarItem.title = oneVc.title
two.title = "3"
two.view.backgroundColor = UIColor.blueColor()
two.tabBarItem.title = two.title
three.title = "4"
three.view.backgroundColor = UIColor.brownColor()
three.tabBarItem.title = three.title
four.title = "123"
four.view.backgroundColor = UIColor.purpleColor()
four.tabBarItem.title = four.title
//创建nav
let nav1 = UINavigationController(rootViewController:vc)
let nav2 = UINavigationController(rootViewController:oneVc)
let nav3 = UINavigationController(rootViewController:two)
let nav4 = UINavigationController(rootViewController:three)
let nav5 = UINavigationController(rootViewController:four)
let tabber = UITabBarController()
tabber.tabBar.tintColor = UIColor.whiteColor()
tabber.viewControllers = [nav1,nav2,nav3,nav4,nav5]
//设置window的根vc
self.window!.rootViewController = tabber
self.window!.makeKeyAndVisible()
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。