Say you have two ViewControllers, A and B, you push B onto the stack when A is the topmost, and you want to customize the back button that appears when B is on top.
Typically, you need to set ViewController A navigationItem.backBarButtonItem .
Instead, you should make ViewController B a custom button on the left side of the navigation bar by setting its navigationItem.leftBarButtonItem .
You have implemented this approach perfectly, except that even if you do not set ViewController A navigationItem.backBarButtonItem , by default you still get the default back button. Thus, the button probably appears on top of your custom back button.
If you set ViewController B navigationItem.hidesBackButton = YES , you should not have any problems.
And in the future, when you implement custom buttons back, you should do this by setting navigationItem.backBarButtonItem instead of navigationItem.leftBarButtonItem . The only thing you need to do is that with this approach, for example, you would use ViewController A navigationItem to change the back button that appears when ViewController B is at the top.
source share