importUIKit
@UIApplicationMain
classAppDelegate:UIResponder,UIApplicationDelegate{
varwindow:UIWindow?
funcapplication(application:UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject:AnyObject]?) ->Bool{
let mainTarBarController =UITabBarController()
let firstVC =ViewController()
let secondVC =SecondViewController()
let thirdVC =thirdViewController()
let forthVC =forthViewController()
let fifthVC =fifthViewController()
let sixVC =sixthViewController()
//let ViewC = ViewController()
letfirstnavc =UINavigationController(rootViewController:firstVC)
window?.rootViewController= firstnavc
letsecondnavc =UINavigationController(rootViewController: secondVC)
letthirdnavc =UINavigationController(rootViewController: thirdVC)
//window?.makeKeyAndVisible()
//mainTarBarController.s
mainTarBarController.viewControllers= [firstnavc,secondnavc,thirdnavc,forthVC,fifthVC,sixVC]
mainTarBarController.delegate=self
firstnavc.tabBarItem.title="首頁"
secondnavc.tabBarItem.title="周邊"
thirdnavc.tabBarItem.title="我的"
forthVC.tabBarItem.title="forth"
fifthVC.tabBarItem.title="fifth"
sixVC.tabBarItem.title="sixth"
window=UIWindow(frame:UIScreen.mainScreen().bounds)
window?.backgroundColor=UIColor.whiteColor()
window?.rootViewController= mainTarBarController
window?.makeKeyAndVisible()
return true
}
}
extension AppDelegate:UITabBarControllerDelegate{
func tabBarController(tabBarController:UITabBarController,didSelectViewController
ViewController:UIViewController){
print(tabBarController.selectedIndex)
print(ViewController)
}
}