2

I am currently implementing the XLPagerTabStrip (https://github.com/xmartlabs/XLPagerTabStrip) which effectively creates a tab bar at the top of the view controller.I make a containerVC

class ContainerVC: ButtonBarPagerTabStripViewController {

let purpleInspireColor = #colorLiteral(red: 0.09759091236, green: 0.5779017098, blue: 1, alpha: 1)

override func viewDidLoad() {
    super.viewDidLoad()

    //self.navigationController?.title = "Oreder Detail"
    self.title  = "Order Detail"
    settings.style.buttonBarBackgroundColor = #colorLiteral(red: 0.09759091236, green: 0.5779017098, blue: 1, alpha: 1)
    settings.style.buttonBarItemBackgroundColor = .white
    settings.style.selectedBarBackgroundColor = #colorLiteral(red: 0.09759091236, green: 0.5779017098, blue: 1, alpha: 1)
    settings.style.buttonBarItemFont = .boldSystemFont(ofSize: 16)
    settings.style.selectedBarHeight = 1.5
    settings.style.buttonBarMinimumLineSpacing = 0
    settings.style.buttonBarItemTitleColor = #colorLiteral(red: 0.09759091236, green: 0.5779017098, blue: 1, alpha: 1)
    settings.style.buttonBarItemsShouldFillAvailiableWidth = true
    settings.style.buttonBarLeftContentInset = 0
    settings.style.buttonBarRightContentInset = 0
    changeCurrentIndexProgressive = { [weak self] (oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in
        guard changeCurrentIndex == true else { return }
        oldCell?.label.textColor = #colorLiteral(red: 0.6666666865, green: 0.6666666865, blue: 0.6666666865, alpha: 1)
        newCell?.label.textColor = self?.purpleInspireColor
    }
}

override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
    let child_1 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "PreOrderVC")
    let child_2 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "PendingVC")
    let child_3 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "PreparingVC")
    let child_4 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "HoldVC")
    let child_5 = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "CompleteVC")


    return [child_1,child_2, child_3, child_4, child_5]
}

@IBAction func leftContainerMenuTapped(_ sender: UIBarButtonItem) {
    panel?.configs = FAPanelConfigurations()
    panel?.openLeft(animated: true)
}}

I used this containerVC in 2 different places first instantiate the viewcontroller in button actions, This will show perfectly fine. shown below:

@IBAction func orderBtnTapped(_ sender: UIButton) {
   // let vc = ContainerVC()
    //self.present(vc, animated: true, completion: nil)
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let vc = storyboard.instantiateViewController(withIdentifier: "ContainerVC") as! ContainerVC
    navigationController?.pushViewController(vc, animated: true)

}

But the issue is when i show this ContainerVC in my side menu which is also a third party library FAPanels. I am having a spacing issue in xlpager tabs. Spacing Tab Bar Image

Code of side Left Menu

override func viewWillAppear(_ animated: Bool) {
    identifierArr = ["HomeVC" , "ContainerVC" ,"floorTableVC", "KitchenScreenVC","KitchenLinesVC" ,"DriverScreenVC", "ReportsContainerVC"]
}
override func viewWillDisappear(_ animated: Bool) {
    identifierArr.removeAll()
}

override func viewWillLayoutSubviews() {
    super.viewWillLayoutSubviews()
    self.imageProfile.layer.cornerRadius = self.imageProfile.frame.size.width / 2;
    self.imageProfile.clipsToBounds = true
}

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return menuOptions.count
}

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
    return 50

}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let cell = leftMenuTableView.dequeueReusableCell(withIdentifier: "SideMenuCell", for: indexPath) as! LeftMenuVCCell
    cell.leftSideMenu.text = menuOptions[indexPath.row]
    cell.selectionStyle = .none
    return cell

}

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {


    let identifier = identifierArr[indexPath.row]
    let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
    let homeVC: UIViewController = mainStoryboard.instantiateViewController(withIdentifier: identifier)
    let centerNavVC = UINavigationController(rootViewController: homeVC)

    panel!.configs.bounceOnCenterPanelChange = true

    panel!.center(centerNavVC, afterThat: {
        print("Executing block after changing center panelVC From Left Menu")
        //            _ = self.panel!.left(nil)
    })


}

}

Mike Shaen
  • 21
  • 4

0 Answers0