Right now I have two view controllers. My problem is I don't know how to hide back button after change into second view controller. Mostly references that I found in objective-C. How I code it in swift?
Hide back button code in objective-c
[self.navigationItem setHidesBackButton:YES animated:YES];
From the UINavigationItem class reference documentation -
self.navigationItem.setHidesBackButton(true, animated:true);
In case you're using a UITabBarController:
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
self.tabBarController?.navigationItem.hidesBackButton = true
}
This is also found in the UINavigationController class documentation:
navigationItem.hidesBackButton = true
Swift
// remove left buttons (in case you added some)
self.navigationItem.leftBarButtonItems = []
// hide the default back buttons
self.navigationItem.hidesBackButton = true
You may try with the below code
override func viewDidAppear(_ animated: Bool) {
self.navigationController?.isNavigationBarHidden = true
}
Go to attributes inspector and uncheck show Navigation Bar to hide back button.