user883884
user883884

Reputation: 33

swift disable pop vc animation when tap on tabbar item

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
}

Upvotes: 1

Views: 233

Answers (1)

RTXGamer
RTXGamer

Reputation: 3714

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
        }
    }
}

Upvotes: 1

Related Questions