The solution below is working for me though it's not an optimal solution:
Invoke the following method from your viewWillAppear()
navigationController?.forceUpdateNavBar()
and create this method in UINavigationController extension
extension UINavigationController {
func forceUpdateNavBar() {
DispatchQueue.main.async {
self.navigationBar.sizeToFit()
}
}
}