Based on the solution from @loo_l
Instead of subclassing UINavigationController or extending it with a new push function, you can achieve the same thing like this.
If you are already setting hidesBottomBarWhenPushed = true manually, you can change it to
hidesBottomBarWhenPushed = navigationController.canHideBottomForNextPush
// hidesBottomBarWhenPushed workaround.
public extension UINavigationController {
// True if `hidesBottomBarWhenPushed` can be set to true, otherwise false.
// Workaround for iOS 14 bug.
var canHideBottomForNextPush: Bool {
// There is a bug in iOS 14 that hides the bottom bar
// when popping multiple navigation controllers from the stack,
// and one of them has hidesBottomBarWhenPushed set to true.
// https://developer.apple.com/forums/thread/660750
guard #available(iOS 14, *) else {
return true
}
return viewControllers.count == 1
}
}