Browse Source

no message

南鑫林 5 years ago
parent
commit
6b5863c70c

+ 57 - 18
RainbowPlanet/RainbowPlanet/Base/BaseTabbarViewController/BaseTabbarViewController.swift

@@ -8,7 +8,7 @@
 
 
 import UIKit
 import UIKit
 
 
-class BaseTabbarViewController: ESTabBarController {
+class BaseTabbarViewController: UITabBarController {
     private static let _sharedInstance = BaseTabbarViewController()
     private static let _sharedInstance = BaseTabbarViewController()
 
 
     class func shared() -> BaseTabbarViewController {
     class func shared() -> BaseTabbarViewController {
@@ -21,25 +21,26 @@ class BaseTabbarViewController: ESTabBarController {
         // Do any additional setup after loading the view.
         // Do any additional setup after loading the view.
     }
     }
     
     
-    func tabBarViewController() -> ESTabBarController {
-        let tabBarViewController = ESTabBarController()
+    func tabBarViewController() -> UITabBarController {
+        let tabBarViewController = UITabBarController()
+        tabBarViewController.delegate = self
         
         
         tabBarViewController.tabBar.shadowImage = UIImage(named: "tab_top_line")
         tabBarViewController.tabBar.shadowImage = UIImage(named: "tab_top_line")
         
         
-        tabBarViewController.shouldHijackHandler = {
-            tabbarController, viewController, index in
-            if index == 2 {
-                return true
-            }
-            return false
-        }
-        
-        tabBarViewController.didHijackHandler = {
-            tabbarController, viewController, index in
-            let pickVc = PublishViewController()
-            let nav = BaseNavigationViewController.init(rootViewController: pickVc)
-            tabbarController.present(nav, animated: true, completion: nil)
-        }
+//        tabBarViewController.shouldHijackHandler = {
+//            tabbarController, viewController, index in
+//            if index == 2 {
+//                return true
+//            }
+//            return false
+//        }
+//
+//        tabBarViewController.didHijackHandler = {
+//            tabbarController, viewController, index in
+//            let pickVc = PublishViewController()
+//            let nav = BaseNavigationViewController.init(rootViewController: pickVc)
+//            tabbarController.present(nav, animated: true, completion: nil)
+//        }
         
         
         /// 社区
         /// 社区
         let v1 = CommunityViewController()
         let v1 = CommunityViewController()
@@ -52,11 +53,20 @@ class BaseTabbarViewController: ESTabBarController {
         /// 我的
         /// 我的
         let v5 = UserPersonalCenterViewController()
         let v5 = UserPersonalCenterViewController()
 
 
+        setupChildController(controller: v1, title: "社区", image: "tabbar_home", selectedImage: "tabbar_home_pre")
+
+        setupChildController(controller: v1, title: "商城", image: "tabbar_home", selectedImage: "tabbar_home_pre")
+
+        setupChildController(controller: v1, title: "", image: "tabbar_home", selectedImage: "tabbar_home_pre")
+
+        setupChildController(controller: v1, title: "社区", image: "tabbar_home", selectedImage: "tabbar_home_pre")
+
+        setupChildController(controller: v1, title: "社区", image: "tabbar_home", selectedImage: "tabbar_home_pre")
+
         v1.tabBarItem = ESTabBarItem.init(BaseIrregularityBasicContentView(),title: "社区", image: UIImage(named: "tabbar_home"), selectedImage: UIImage(named: "tabbar_home_pre"))
         v1.tabBarItem = ESTabBarItem.init(BaseIrregularityBasicContentView(),title: "社区", image: UIImage(named: "tabbar_home"), selectedImage: UIImage(named: "tabbar_home_pre"))
         v2.tabBarItem = ESTabBarItem.init(BaseIrregularityBasicContentView(),title: "商城", image: UIImage(named: "tabbar_shopping"), selectedImage: UIImage(named: "tabbar_shopping_pre"))
         v2.tabBarItem = ESTabBarItem.init(BaseIrregularityBasicContentView(),title: "商城", image: UIImage(named: "tabbar_shopping"), selectedImage: UIImage(named: "tabbar_shopping_pre"))
         v3.tabBarItem = ESTabBarItem.init(BaseIrregularityContentView(), title: nil, image: UIImage(named: "tabbar_publish"), selectedImage: UIImage(named: "tabbar_publish"))
         v3.tabBarItem = ESTabBarItem.init(BaseIrregularityContentView(), title: nil, image: UIImage(named: "tabbar_publish"), selectedImage: UIImage(named: "tabbar_publish"))
         v4.tabBarItem = ESTabBarItem.init(BaseIrregularityBasicContentView(),title: "消息", image: UIImage(named: "tabbar_massage"), selectedImage: UIImage(named: "tabbar_massage_pre"))
         v4.tabBarItem = ESTabBarItem.init(BaseIrregularityBasicContentView(),title: "消息", image: UIImage(named: "tabbar_massage"), selectedImage: UIImage(named: "tabbar_massage_pre"))
-        v4.tabBarItem.pp.addBadge(number: 1)
         v5.tabBarItem = ESTabBarItem.init(BaseIrregularityBasicContentView(),title: "我的", image: UIImage(named: "tabbar_my"), selectedImage: UIImage(named: "tabbar_my_pre"))
         v5.tabBarItem = ESTabBarItem.init(BaseIrregularityBasicContentView(),title: "我的", image: UIImage(named: "tabbar_my"), selectedImage: UIImage(named: "tabbar_my_pre"))
         
         
         let n1 = BaseNavigationViewController.init(rootViewController: v1)
         let n1 = BaseNavigationViewController.init(rootViewController: v1)
@@ -69,5 +79,34 @@ class BaseTabbarViewController: ESTabBarController {
         
         
         return tabBarViewController
         return tabBarViewController
     }
     }
+    
+    func setupChildController(controller: UIViewController, title: String, image: String, selectedImage: String) {
+        
+        controller.tabBarItem.title = title
+        controller.tabBarItem.image = UIImage.init(named: image)?.withRenderingMode(.alwaysOriginal)
+        controller.tabBarItem.selectedImage = UIImage.init(named: selectedImage)?.withRenderingMode(.alwaysOriginal)
+        self.addChild(BaseNavigationViewController.init(rootViewController: controller))
+        
+    }
+
+}
 
 
+extension BaseTabbarViewController : UITabBarControllerDelegate {
+    func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
+        if tabBarController.tabBar.selectedItem?.tag == 2 {
+            return false
+        }else{
+            return true
+        }
+    }
+    
+    override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
+        if item.tag == 3 {
+            let pickVc = PublishViewController()
+            let nav = BaseNavigationViewController.init(rootViewController: pickVc)
+            self.tabBarViewController().present(nav, animated: true, completion: nil)
+        }
+    }
 }
 }
+
+

+ 0 - 14
RainbowPlanet/RainbowPlanet/Tools/ESTabBarController-swift/ESTabBarItem.swift

@@ -65,20 +65,6 @@ open class ESTabBarItem: UITabBarItem {
         didSet { self.contentView?.selectedImage = selectedImage }
         didSet { self.contentView?.selectedImage = selectedImage }
     }
     }
     
     
-    open override var badgeValue: String? // default is nil
-        {
-        get { return contentView?.badgeValue }
-        set(newValue) { contentView?.badgeValue = newValue }
-    }
-    
-    /// Override UITabBarItem.badgeColor, make it available for iOS8.0 and later.
-    /// If this item displays a badge, this color will be used for the badge's background. If set to nil, the default background color will be used instead.
-    @available(iOS 8.0, *)
-    open override var badgeColor: UIColor? {
-        get { return contentView?.badgeColor }
-        set(newValue) { contentView?.badgeColor = newValue }
-    }
-    
     open override var tag: Int // default is 0
     open override var tag: Int // default is 0
         {
         {
         didSet { self.contentView?.tag = tag }
         didSet { self.contentView?.tag = tag }