OOTabBarHelper.swift 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // OOTabBarHelper.swift
  3. // O2Platform
  4. //
  5. // Created by 刘振兴 on 2018/4/12.
  6. // Copyright © 2018年 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. import CYLTabBarController
  10. class OOTabBarHelper: NSObject {
  11. static func viewControllers() -> [ZLNavigationController] {
  12. //消息
  13. let conversationVC = JCConversationListViewController()
  14. conversationVC.title = "消息"
  15. let messages = ZLNavigationController(rootViewController: conversationVC)
  16. //通讯录
  17. let addressVC = OOTabBarHelper.getVC(storyboardName: "contacts", vcName: nil)
  18. let address = ZLNavigationController(rootViewController: addressVC)
  19. //应用
  20. let appsVC = OOTabBarHelper.getVC(storyboardName: "apps", vcName: nil)
  21. let apps = ZLNavigationController(rootViewController: appsVC)
  22. //设置
  23. let settingsVC = OOTabBarHelper.getVC(storyboardName: "setting", vcName: nil)
  24. let settings = ZLNavigationController(rootViewController: settingsVC)
  25. let viewControllers = [messages, address, apps, settings]
  26. return viewControllers
  27. }
  28. static func tabBarItemsAttributesForController() -> [[String : String]] {
  29. let tabBarItemOne = [CYLTabBarItemTitle:"消息",
  30. CYLTabBarItemImage:"message_normal",
  31. CYLTabBarItemSelectedImage:"message_selected"]
  32. let tabBarItemTwo = [CYLTabBarItemTitle:"通讯录",
  33. CYLTabBarItemImage:"address_normal",
  34. CYLTabBarItemSelectedImage:"address_selected"]
  35. let tabBarItemThree = [CYLTabBarItemTitle:"应用",
  36. CYLTabBarItemImage:"apps_normal",
  37. CYLTabBarItemSelectedImage:"apps_selected"]
  38. let tabBarItemFour = [CYLTabBarItemTitle:"设置",
  39. CYLTabBarItemImage:"setting_normal",
  40. CYLTabBarItemSelectedImage:"setting_selected"]
  41. let tabBarItemsAttributes = [tabBarItemOne,tabBarItemTwo,tabBarItemThree,tabBarItemFour]
  42. return tabBarItemsAttributes
  43. }
  44. static func getVC(storyboardName:String,vcName:String?) -> UIViewController {
  45. let storyBoard:UIStoryboard = UIStoryboard.init(name: storyboardName, bundle: nil)
  46. var destVC:UIViewController!
  47. if vcName != nil {
  48. destVC = storyBoard.instantiateViewController(withIdentifier: vcName!)
  49. }else{
  50. destVC = storyBoard.instantiateInitialViewController()
  51. }
  52. return destVC
  53. }
  54. static func initTabBarStyle() {
  55. UITabBarItem.appearance().setTitleTextAttributes([
  56. NSAttributedString.Key.font: UIFont.init(name: "PingFangSC-Regular", size: 12) ?? UIFont.systemFont(ofSize: 12),
  57. NSAttributedString.Key.foregroundColor: UIColor(hex: "#666666")], for: .normal)
  58. UITabBarItem.appearance().setTitleTextAttributes([
  59. NSAttributedString.Key.font: UIFont.init(name: "PingFangSC-Regular", size: 12) ?? UIFont.systemFont(ofSize: 12),
  60. NSAttributedString.Key.foregroundColor: base_color], for: .selected)
  61. UITabBar.appearance().backgroundColor = UIColor(hex: "#F7F7F7")
  62. }
  63. }