| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- //
- // MainViewController.swift
- // MTP2_iOS
- //
- // Created by zhongyuan on 2018/5/19.
- // Copyright © 2018年 zhongyuan.All rights reserved.
- //
- import UIKit
- import NVActivityIndicatorView
- import WHToast
- /// 主窗体
- class MainViewController: UITabBarController {
- // MARK: - 生命周期相关
- override func viewDidLoad() {
- super.viewDidLoad()
- /// 设置委托代理
- self.delegate = self
- /// 初始化界面
- buildView()
- }
- // MARK: - 加载配置项功能相关
- private func buildView() {
- /// 设置tabbar背景色
- self.tabBar.barTintColor = UIColor.white
- /// 去掉毛玻璃效果
- self.tabBar.isTranslucent = false
-
- if let fundations = ConfigUtils.getValue(key: .functionModule) as? [String] {
- var viewcontrollers = [UIViewController]()
- for id in fundations {
- if id == "Home" { /// 首页
- let navigationController = UIStoryboard(name: "Home", bundle: nil).instantiateViewController(withIdentifier: "Home") as! BaseNavigationController
- viewcontrollers.append(navigationController)
- } else if id == "Mine" { /// 我的页面
- let navigationController = UIStoryboard(name: "Mine", bundle: nil).instantiateViewController(withIdentifier: "Mine") as! BaseNavigationController
- viewcontrollers.append(navigationController)
- } else if id == "Quote" { /// 行情
- let navigationController = UIStoryboard(name: "Quote", bundle: nil).instantiateViewController(withIdentifier: "Quote") as! BaseNavigationController
- viewcontrollers.append(navigationController)
- } else if id == "Message" { /// 消息
- let navigationController = UIStoryboard(name: "Message", bundle: nil).instantiateViewController(withIdentifier: "Message") as! BaseNavigationController
- viewcontrollers.append(navigationController)
- }
- }
- self.viewControllers = viewcontrollers
- }
- }
- }
- extension MainViewController: UITabBarControllerDelegate {
- func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
- /// 未登录
- if let sub = (viewController as? BaseNavigationController)?.viewControllers[0],
- sub.isKind(of: MessageViewController.self),
- !MTP2BusinessCore.shared.getLoginStatus() {
- /// 弹出登录页面
- tabBarController.viewControllers?[0].present(storyboardName: "Main", storyboardId: "Login")
- return false
- }
- return true
- }
- }
|