I am trying to hide status bar in one of my UIViewControllers (Swift 4).
Firstly, I set View controller-based status bar appearance to
As you said, you are using UINavigationController to navigate to your custom view controller. I suppose you have set your Custom View controller as the root view of your UINavigationController. In this case overriding var prefersStatusBarHidden in your custom view controller won't work but you will have to subclass your UINavigation Controller and override the property there as shown below:-
class CustomNavigationController: UINavigationController {
override var prefersStatusBarHidden: Bool {
return true
}
}