Ahmadalsofi / SOTabBar

Light way to add Fancy bottom bar 📲
MIT License
675 stars 71 forks source link

HOW TO NAVIGATE THE ANOTHER TABBAR ON BUTTON CLICK #20

Open Shubham0816 opened 3 years ago

MeetBudheliya commented 2 years ago

i'm trying to find it, but not get it... @Ahmadalsofi Please guide us if you have any idea about this...

khushalhoch23 commented 7 months ago

@Ahmadalsofi

I have solution for above issue, follow the steps.

Line No : 137 , Class SOTabBar

func didSelectTab(index: Int) {
        if index + 1 == selectedIndex {return}
        animateTitle(index: index)

        previousSelectedIndex = selectedIndex
        selectedIndex  = index + 1

        delegate?.tabBar(self, didSelectTabAt: index)
        animateCircle(with: circlePath)
        animateImage()

        guard let image = self.viewControllers[index].tabBarItem.selectedImage else {
            fatalError("You should insert selected image to all View Controllers")
        }
        self.tabSelectedImageView.image = image
    }

Step 2: class SOTabBarController, set below function at line no : 77

func preSelectedIndex(index: Int){
        self.tabBar.didSelectTab(index: index)
    }

Step 3: Call the function from your Tabbar class

class UTabbarVC: SOTabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        self.delegate = self
// your VC setup here
...
// set here you want to selected index
preSelectedIndex(index: 1)
      }
}