I am struggling to hide the navigationBar
, which would properly be hidden if the root controller wasn't a SwiftUI UIHostingController
.
I tried the following:
Setting
navigationController.isNavigationBarHidden = true
after creating it, atviewDidLoad
andviewWillAppear
.Adding both
.navigationBarHidden(true)
and.navigationBarBackButtonHidden(true)
for theUIHostingController
'srootView
.
Could it be an Apple bug? I am using Xcode 11.6.
All my attempts together:
class LoginController: UINavigationController, ObservableObject
{
static var newAccount: LoginController
{
let controller = LoginController()
let view = LoginViewStep1()
.navigationBarHidden(true)
.navigationBarBackButtonHidden(true)
controller.viewControllers = [UIHostingController(rootView: view)]
controller.isNavigationBarHidden = true
return controller
}
override func viewWillAppear(_ animated: Bool)
{
super.viewWillAppear(animated)
self.isNavigationBarHidden = true
}
override func viewDidLoad()
{
super.viewDidLoad()
self.isNavigationBarHidden = true
}
}
struct LoginViewStep1: View
{
// ...
var body: some View
{
VStack {
// ...
}
.navigationBarHidden(true)
.navigationBarBackButtonHidden(true)
}
}