OOPlusButtonSubclass.swift 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // OOPlusButton.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. import CocoaLumberjack
  11. import O2OA_Auth_SDK
  12. class OOPlusButtonSubclass: CYLPlusButton,CYLPlusButtonSubclassing {
  13. static func plusButton() -> Any! {
  14. let button = OOPlusButtonSubclass()
  15. let normalImage = OOCustomImageManager.default.loadImage(.index_bottom_menu_logo_blur)
  16. let selectedImage = OOCustomImageManager.default.loadImage(.index_bottom_menu_logo_focus)
  17. button.frame.size.width = 80
  18. button.frame.size.height = 80
  19. button.setImage(normalImage, for: .normal)
  20. button.setImage(selectedImage, for: .selected)
  21. button.isSelected = true
  22. button.titleLabel?.textAlignment = .center
  23. button.titleLabel?.font = UIFont.init(name: "PingFangSC-Regular", size: 12)
  24. button.setTitle("首页", for: .normal)
  25. button.setTitleColor(UIColor(hex:"#666666"), for: .normal)
  26. button.setTitle("首页", for: .selected)
  27. button.theme_setTitleColor(ThemeColorPicker(keyPath: "Base.base_color"), forState: .selected)
  28. //button.adjustsImageWhenHighlighted = false
  29. button.sizeToFit()
  30. return button
  31. }
  32. static func indexOfPlusButtonInTabBar() -> UInt {
  33. return 2
  34. }
  35. static func multiplier(ofTabBarHeight tabBarHeight: CGFloat) -> CGFloat {
  36. return 0.3
  37. }
  38. static func constantOfPlusButtonCenterYOffset(forTabBarHeight tabBarHeight: CGFloat) -> CGFloat {
  39. return 0
  40. }
  41. static func plusChildViewController() -> UIViewController! {
  42. // let vc = PublishViewController()
  43. // let nav = UINavigationController(rootViewController: vc)
  44. // return nav
  45. let appid = O2AuthSDK.shared.customStyle()?.indexPortal
  46. let indexType = O2AuthSDK.shared.customStyle()?.indexType ?? "default"
  47. if indexType == "portal" {
  48. let app = OOAppsInfoDB.shareInstance.queryData(appid!)
  49. let destVC = OOTabBarHelper.getVC(storyboardName: "apps", vcName: "OOMainWebVC")
  50. MailViewController.app = app
  51. (destVC as? MailViewController)?.isIndexShow = true
  52. let nav = ZLNavigationController(rootViewController: destVC)
  53. return nav
  54. }else{
  55. let destVC = OOTabBarHelper.getVC(storyboardName: "task", vcName: nil)
  56. let nav = ZLNavigationController(rootViewController: destVC)
  57. return nav
  58. }
  59. }
  60. static func shouldSelectPlusChildViewController() -> Bool {
  61. return true
  62. }
  63. override func layoutSubviews() {
  64. super.layoutSubviews()
  65. // tabbar UI layout setup
  66. let imageViewEdgeWidth:CGFloat = self.bounds.size.width * 0.75
  67. let imageViewEdgeHeight:CGFloat = imageViewEdgeWidth * 0.9
  68. let centerOfView = self.bounds.size.width * 0.5
  69. let labelLineHeight = self.titleLabel!.font.lineHeight
  70. let verticalMargin = (self.bounds.size.height - labelLineHeight - imageViewEdgeHeight ) * 0.5
  71. let centerOfImageView = verticalMargin + imageViewEdgeHeight * 0.5
  72. let centerOfTitleLabel = imageViewEdgeHeight + verticalMargin * 2 + labelLineHeight * 0.5 + 10
  73. //imageView position layout
  74. self.imageView!.bounds = CGRect(x:0, y:0, width:imageViewEdgeWidth, height:imageViewEdgeHeight)
  75. self.imageView!.center = CGPoint(x:centerOfView, y:centerOfImageView)
  76. //title position layout
  77. self.titleLabel!.bounds = CGRect(x:0, y:0, width:self.bounds.size.width,height:labelLineHeight)
  78. self.titleLabel!.center = CGPoint(x:centerOfView, y:centerOfTitleLabel)
  79. }
  80. }