Open stwie111 opened 4 years ago
I also tried changing in
class SOTabBar: UIView
internal var viewControllers = [UIViewController]() {
didSet {
drawTabs()
guard !viewControllers.isEmpty else { return }
drawConstraint()
layoutIfNeeded()
didSelectTab(index: 2)
}
}
It would be great if there is a function to change the selectedTab from any of the child class.
My solution is, copy the 4 swift files form Pod in your Project and delete the pod. After that you can modify the didSelectTab(index: 1)
in public class SOTabBar: UIView
.
Hi @kaigothe, did you find the solution if so, you can push it to the repo and we are happy to have you with us as a contributor .
Any solution for this??
My solution is, copy the 4 swift files form Pod in your Project and delete the pod. After that you can modify the
didSelectTab(index: 1)
inpublic class SOTabBar: UIView
.
@kaigothe Thanks, it's working...
Hi @kaigothe, did you find the solution if so, you can push it to the repo and we are happy to have you with us as a contributor .
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)
}
}
i am trying to set initial index to '2' but it's not working. I even tried to change the selectedIndex in the library but its not working.
i also tried to set the index in the podfile but it's not working for me.
open class SOTabBarController: UIViewController, SOTabBarDelegate {