ios 中的uitabbarcontroler 和Android中的tabhost 实现的效果是一样的
// // 得到屏幕window // self.window=UIWindow(frame: UIScreen.mainScreen().bounds) // self.window!.backgroundColor=UIColor.whiteColor() //创建4个界面 //战绩 let zj:UIViewController=ZhanjiViewController() let navZj=UINavigationController(rootViewController: zj) navZj.tabBarItem=UITabBarItem(title: "战绩", image: UIImage(named: "icon_nav_record"), selectedImage: UIImage(named: "icon_nav_record_selected")) //列表 let lb:UIViewController=LieBiaoViewController() let navLb=UINavigationController(rootViewController: lb) navLb.tabBarItem=UITabBarItem(title: "列表", image: UIImage(named: "icon_nav_chat"), selectedImage: UIImage(named: "icon_nav_chat_selected")) //资讯 let zx:UIViewController=ZiXunViewController() let navZx=UINavigationController(rootViewController: zx) navZx.tabBarItem=UITabBarItem(title: "资讯", image: UIImage(named: "icon_nav_news"), selectedImage: UIImage(named: "icon_nav_news_selected")) //设置 let sz:UIViewController=SheZhiViewController() let navSz=UINavigationController(rootViewController: sz) navSz.tabBarItem=UITabBarItem(title: "设置", image: UIImage(named: "icon_nav_tool"), selectedImage: UIImage(named: "icon_nav_tool_selected")) let arr=[navZj,navLb,navZx,navSz] //let tabbarController:UITabBarController=UITabBarController() self.viewControllers=arr //修改tabbar的背景色 //tabbarController.tabBar.barTintColor=UIColor(red: 19.0/255, green: 32.0/255, blue: 36.0/255, alpha: 1.0) self.tabBar.barTintColor=UIColor(patternImage: UIImage(named: "bg_tab_bar")) // self.window!.rootViewController=tabbarController // self.window!.makeKeyAndVisible()
下面是效果图
浙公网安备 33010602011771号