How to push two view controllers but animate transition only for the second one?

前端 未结 7 1457
温柔的废话
温柔的废话 2020-12-04 17:46

I have three controllers (FirstVC, SecondVC, ThirdVC) inside storyboad, and navigation is sequential: a user can navigate from FirstVC to SecondVC, and then to ThirdVC. Now,

相关标签:
7条回答
  • 2020-12-04 18:30

    I use the following snippet to push multiple View Controllers:

    extension UINavigationController {
        func push(_ viewControllers: [UIViewController]) {
            setViewControllers(self.viewControllers + viewControllers, animated: true)
        }
    
        // Also had this in here, left it in as a bonus :)
        func popViewControllers(_ count: Int) {
            guard viewControllers.count > count else { return }
            popToViewController(viewControllers[viewControllers.count - count - 1], animated: true)
        }
    }
    
    0 讨论(0)
提交回复
热议问题