import UIKit
class MainTabViewController: UITabBarController {
let home = HomeViewController()
let market = UIViewController()
let news = NewsViewController()
let edu = EduViewController()
let trade = UIViewController()
override func viewDidLoad() {
super.viewDidLoad()
setupBranches()
tabBar.isTranslucent = false
let naviNews = UINavigationController(rootViewController: news)
naviNews.navigationBar.isTranslucent = false
naviNews.navigationBar.barTintColor = PermanentUI.naviBarTintColor
naviNews.navigationBar.tintColor = .white
let naviEdu = UINavigationController(rootViewController: edu)
naviEdu.navigationBar.isTranslucent = false
naviEdu.navigationBar.barTintColor = PermanentUI.naviBarTintColor
naviEdu.navigationBar.tintColor = .white
let viewControllers = [home, market, naviNews, naviEdu, trade]
setViewControllers(viewControllers, animated: false)
}
private func setupBranches() {
setupHome()
setupMarket()
setupNews()
setupEdu()
setupTrade()
}
private func setupHome() {
home.tabBarItem.image = #imageLiteral(resourceName: "tab_home")
home.tabBarItem.selectedImage = #imageLiteral(resourceName: "tab_home_selected")
home.tabBarItem.title = "首页"
}
private func setupMarket() {
market.tabBarItem.image = #imageLiteral(resourceName: "tab_market")
market.tabBarItem.selectedImage = #imageLiteral(resourceName: "tab_market_selected")
market.tabBarItem.title = "行情"
}
private func setupNews() {
news.tabBarItem.image = #imageLiteral(resourceName: "tab_news")
news.tabBarItem.selectedImage = #imageLiteral(resourceName: "tab_news_selected")
news.tabBarItem.title = "咨询"
}
private func setupEdu() {
edu.tabBarItem.image = #imageLiteral(resourceName: "tab_edu")
edu.tabBarItem.selectedImage = #imageLiteral(resourceName: "tab_edu_selected")
edu.tabBarItem.title = "投教"
}
private func setupTrade() {
trade.tabBarItem.image = #imageLiteral(resourceName: "tab_trade")
trade.tabBarItem.selectedImage = #imageLiteral(resourceName: "tab_trade_selected")
trade.tabBarItem.title = "交易"
}
}
网友评论