您好,登錄后才能下訂單哦!
//創(chuàng)建window
self.window = UIWindow(frame:UIScreen.mainScreen().bouns)
//設(shè)置根VC
self.window!.rootViewController = ViewController()
//創(chuàng)建一個(gè)btn
var btn = UIButton (frame:CGRect(x: 100, y: 100, width: 100, height: 100))
// 設(shè)置背景顏色
btn.backgroundColor = UIColor.yellowColor();
// 將添加到我們的vc上
self.window!.rootViewController!.view.addSubview(btn)
self.window!.makeKeyAndVisible()
//創(chuàng)建window
self.window = UIWindow(frame:UIScreen.mainScreen().bounds)
//創(chuàng)建VC
let vc = ViewController()
let oneVc = OnrViewController()
let two = TwoViewController()
let three = ThreeViewController()
let four = FourViewController()
//設(shè)置背景顏色
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
//創(chuàng)建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]
//設(shè)置window的根vc
self.window!.rootViewController = tabber
self.window!.makeKeyAndVisible()
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。