Swift push并移除当前页

2021-07-08  本文已影响0人  Mr_xuy
extension UINavigationController {
    
    /// 向前 push 跳转并移除当前页
    /// - Parameter toVc: 跳转的页面
    internal func pushAndRemoveCurrent(toVc: UIViewController) {
        var newNavViews: Array<UIViewController> = []
        for index in 0..<(viewControllers.count - 1) {
            let vc: UIViewController = viewControllers[index]
            newNavViews.append(vc)
        }
        newNavViews.append(toVc)
        setViewControllers(newNavViews, animated: true)
    }
}
上一篇下一篇

猜你喜欢

热点阅读