您好,登錄后才能下訂單哦!
//創建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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。