alqindiirsyam 2 lat temu
rodzic
commit
84d8a74490

+ 9 - 27
appbuilder-ios/AppBuilder/AppBuilder/ViewController.swift

@@ -120,22 +120,10 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
         
         self.delegate = self
         
-        
-        firstTab?.tabBarItem.image = resizeImage(image: UIImage(named: "tab_1_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal)
-        firstTab?.tabBarItem.imageInsets = UIEdgeInsets.init(top: 5,left: 0,bottom: -5,right: 0)
-        secondTab?.tabBarItem.image = resizeImage(image: UIImage(named: "tab_2_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal)
-        secondTab?.tabBarItem.imageInsets = UIEdgeInsets.init(top: 5,left: 0,bottom: -5,right: 0)
-        thirdTab?.tabBarItem.image = resizeImage(image: UIImage(named: "tab_3_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal)
-        thirdTab?.tabBarItem.imageInsets = UIEdgeInsets.init(top: 5,left: 0,bottom: -5,right: 0)
-        fourthTab?.tabBarItem.image = resizeImage(image: UIImage(named: "tab_4_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal)
-        fourthTab?.tabBarItem.imageInsets = UIEdgeInsets.init(top: 5,left: 0,bottom: -5,right: 0)
-        let iPhoneModel = getiPhoneModel()
-        if iPhoneModel == "iPhone X or newer" {
-            firstTab?.tabBarItem.imageInsets = UIEdgeInsets.init(top: 25,left: 0,bottom: -25,right: 0)
-            secondTab?.tabBarItem.imageInsets = UIEdgeInsets.init(top: 25,left: 0,bottom: -25,right: 0)
-            thirdTab?.tabBarItem.imageInsets = UIEdgeInsets.init(top: 25,left: 0,bottom: -25,right: 0)
-            fourthTab?.tabBarItem.imageInsets = UIEdgeInsets.init(top: 25,left: 0,bottom: -25,right: 0)
-        }
+        firstTab?.tabBarItem = UITabBarItem(title: "", image: resizeImage(image: UIImage(named: "tab_1_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(named: "tab_1_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal).withTintColor(.mainColor))
+        secondTab?.tabBarItem = UITabBarItem(title: "", image: resizeImage(image: UIImage(named: "tab_2_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(named: "tab_2_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal).withTintColor(.mainColor))
+        thirdTab?.tabBarItem = UITabBarItem(title: "", image: resizeImage(image: UIImage(named: "tab_3_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(named: "tab_3_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal).withTintColor(.mainColor))
+        fourthTab?.tabBarItem = UITabBarItem(title: "", image: resizeImage(image: UIImage(named: "tab_4_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(named: "tab_4_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal).withTintColor(.mainColor))
         var i = 0
         var j = 0
         while j < customTab.count {
@@ -219,12 +207,6 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
             }
             self.tabBar.items?[2].isEnabled = false
         }
-        let numberOfItems = CGFloat(tabBar.items!.count)
-        let tabBarItemSize = CGSize(width: tabBar.frame.width / numberOfItems, height: tabBar.frame.height)
-        tabBar.selectionIndicatorImage = UIImage.imageWithColor(color: UIColor.black.withAlphaComponent(0.2), size: tabBarItemSize).resizableImage(withCapInsets: .zero)
-        if Bundle.main.displayName == "DigiNetS" {
-            tabBar.selectionIndicatorImage = UIImage.imageWithColor(color: UIColor.gray, size: tabBarItemSize).resizableImage(withCapInsets: .zero)
-        }
         let center: NotificationCenter = NotificationCenter.default
         center.addObserver(self, selector: #selector(checkCounter), name: NSNotification.Name(rawValue: Nexilis.listenerReceiveChat), object: nil)
         center.addObserver(self, selector: #selector(checkCounter), name: NSNotification.Name(rawValue: "reloadTabChats"), object: nil)
@@ -485,14 +467,14 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
         ViewController.postButton.layer.shadowOffset = CGSize(width: 4, height: 4)
         ViewController.postButton.addTarget(self, action: #selector(postTap), for: .touchUpInside)
         let buttonCenterX = self.view.bounds.width / 2
-        let buttonCenterY = self.view.bounds.height - self.tabBar.bounds.height
-        //print("buttonCenterX \(buttonCenterX)")
-        //print("buttonCenterY \(buttonCenterY)")
-        ViewController.middleButton = UIButton(frame: CGRect(x: buttonCenterX - 40 , y: buttonCenterY - 40, width: 80, height: 80))
+        var buttonCenterY = self.view.bounds.height - self.tabBar.bounds.height
         let iPhoneModel = getiPhoneModel()
         if iPhoneModel == "iPhone X or newer" {
-            ViewController.middleButton = UIButton(frame: CGRect(x: buttonCenterX - 40 , y: buttonCenterY - 60, width: 80, height: 80))
+            buttonCenterY -= 30
         }
+        //print("buttonCenterX \(buttonCenterX)")
+        //print("buttonCenterY \(buttonCenterY)")
+        ViewController.middleButton = UIButton(frame: CGRect(x: buttonCenterX - 40 , y: buttonCenterY - 40, width: 80, height: 80))
         if PrefsUtil.getIconDock() != nil {
             DispatchQueue.global().async {
                 ViewController.getDataImageFromUrl(from: URL(string: PrefsUtil.getUrlDock()!)!) { data, response, error in