Swift标签控制器

let vc1 = XinwenViewController()
let nav1 = UINavigationController(rootViewController: vc1)
nav1.tabBarItem = UITabBarItem(title: “首页”, image: UIImage(named: “dongTai”), selectedImage: UIImage(named: “dongTai_H”))

    let vc2 = ShequViewController()
    let nav2 = UINavigationController(rootViewController: vc2)
    nav2.tabBarItem = UITabBarItem(title: "返现", image: UIImage(named: "dongTai"), selectedImage: UIImage(named: "dongTai_H"))
    
    let vc3 = TouyanViewController()
    let nav3 = UINavigationController(rootViewController: vc3)
    nav3.tabBarItem = UITabBarItem(title: "购物", image: UIImage(named: "dongTai"), selectedImage: UIImage(named: "dongTai_H"))
    
    let vc4 = WodeViewController()
    let nav4 = UINavigationController(rootViewController: vc4)
    nav4.tabBarItem = UITabBarItem(title: "我的", image: UIImage(named: "dongTai"), selectedImage: UIImage(named: "dongTai_H"))
    
    let tbv = UITabBarController()
    tbv.viewControllers = [nav1,nav2,nav3,nav4]
    tbv.selectedViewController = nav2
    self.window?.rootViewController = tbv

你可能感兴趣的:(Swift标签控制器)