Home > Blockchain >  swift disable pop vc animation when tap on tabbar item
swift disable pop vc animation when tap on tabbar item

Time:09-16

I have a tabbarcontroller when i tap on item which is selected then navigationController do pop to root vc. How can i disable animation ? i want that it will do pop to root vc but without animation

i can just disable pop to root vc, but dont know how to disable animation

func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
    return viewController != selectedViewController
}

CodePudding user response:

Try popToRootViewController programmatically when tap is detected:

extension ARTabBar: UITabBarControllerDelegate {
    func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
        if viewController == selectedViewController {
            if let viewController = viewController as? UINavigationController {
                viewController.popToRootViewController(animated: false)
            }
            return false
        } else {
            return true
        }
    }
}
  • Related