Sometimes, we need to change the back button's image on UINavigationBar. Many articles introduce a method in which you need to change the back button in the corresponding view controller.
for example:
Assuming you have a view controller called TestViewController controlled by the UINavigationController, then you can set the back button in the viewDidLoad method
then you still need to add event handle:
But, if you have multiple view controllers, you have to add the above code in each controller. so to reuse the code, I try to subclass the UINavigationController and try to customize the back button in the pushViewController method.
for example:
More explaining on this method, you have to create a new back button for each viewController. if you reuse one button
for each view controller, there will be some display problem-- some view controller's button may not be displayed, I'm
not very clear about it now.