Ios – Swift – How to hide back button in navigation item

iosswift

Right now I have two view controllers. My problem is I don't know how to hide the back button after transitioning to the second view controller. Most references that I found are in Objective-C. How do I code it in Swift?

Hide back button code in Objective-C

[self.navigationItem setHidesBackButton:YES animated:YES];

Best Answer

According to the documentation for UINavigationItem :

self.navigationItem.setHidesBackButton(true, animated: true)