美文网首页
Swift push并移除当前页

Swift push并移除当前页

作者: Mr_xuy | 来源:发表于2021-07-08 15:12 被阅读0次
    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)
        }
    }
    

    相关文章

      网友评论

          本文标题:Swift push并移除当前页

          本文链接:https://www.haomeiwen.com/subject/ffktpltx.html