首页 > 解决方案 > 顶部栏显示过渡到根视图控制器 Swift

问题描述

我有一个快速的应用程序,

在我的应用程序中,我想在登录或注销后重新启动应用程序(或转换到根视图控制器)。

我使用该代码重新启动我的应用程序

 func restartApplication () {
    let initialViewController  =  UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "TabBarVC")
     
     let navCtrl = UINavigationController(rootViewController: initialViewController)
     guard
             let window = UIApplication.shared.keyWindow,
             let rootViewController = window.rootViewController
             else {
         return
     }

     navCtrl.view.frame = rootViewController.view.frame
     rootViewController.modalPresentationStyle = .fullScreen //or .overFullScreen for transparency
     window.isHidden = false
     
     UIView.transition( with: window, duration: 0.3, options: .beginFromCurrentState, animations: {

         window.rootViewController = navCtrl
     })

 }

标签: iosswift

解决方案


添加

navCtrl.isNavigationBarHidden = true

推荐阅读