OOPlusButtonSubclass.swift 3.9 KB

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