class RootTabBarController: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
self.tabBar.barTintColor = UIColor.white
self.tabBar.isTranslucent = false
self.tabBar.backgroundColor = UIColor.white
self.navigationController?.navigationBar.isHidden = true
self.tabBar.layer.borderWidth = 0.50
self.tabBar.layer.borderColor = UIColor.groupTableViewBackground.cgColor
self.tabBar.shadowImage = UIImage()
self.tabBar.backgroundImage = UIImage()
self.createThirdItemTabBar()
self.createThirdItemTabBarImage()
}
//MARK: - 创建3个TabBar
func createThirdItemTabBar() {
/**首页*/
let homeVC = HomeVC()
let homeNav = BaseNavigationViewController(rootViewController: homeVC)
let loanVC = LoanVC()
let loanNav = BaseNavigationViewController(rootViewController: loanVC)
/**我的 */
let mineVC = MineVC()
let mineNav = BaseNavigationViewController(rootViewController: mineVC)
self.viewControllers = [homeNav, loanNav, mineNav]
}
// MARK: 创建3个TabBar的图标
func createThirdItemTabBarImage() {
let unSelectImage = ["home_unselect", "investment_unselect","my_unselect"]
let selectImage = ["home_select", "investment_select","my_select"]
let tabbarName = ["首页", "贷款", "我的"]
for (index, item) in (self.tabBar.items?.enumerated())! {
item.title = tabbarName[index]
item.selectedImage = UIImage(named: selectImage[index])?.withRenderingMode(.alwaysOriginal)
item.image = UIImage(named: unSelectImage[index])?.withRenderingMode(.alwaysOriginal)
item.tag = index
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}