我想用 Tab bar 來當作我 app的樣板,所以來學習一下
//create a window and setup the background color
self.window = UIWindow.init(frame:UIScreen.main.bounds)
self.window?.backgroundColor = UIColor.white
//create mytabBar and setup the background color
let mytabBar = UITabBarController()
mytabBar.tabBar.backgroundColor = UIColor.gray
let mainViewController = ViewController()
mainViewController.tabBarItem = UITabBarItem(tabBarSystemItem: .favorites, tag: 200)
let qRCodeController = QRCodeController()
qRCodeController.tabBarItem = UITabBarItem(title: "QR Code", image: UIImage(named:"qrcode"), tag: 200)
let cameraScannerController = CameraScannerController()
cameraScannerController.tabBarItem = UITabBarItem(title: "數字辨識", image: UIImage(named:"camerascanner"), tag: 200)
myTabBar.viewControllers = [mainViewController,cameraScannerController,qRCodeController]
myTabBar.selectedIndex = 0
self.window!.rootViewController = myTabBar
self.window!.makeKeyAndVisible()
載入item的圖檔不可以太大,目前試到 32 pixels 是不會爆掉的最大值