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.
自定义UINavigationController返回按钮
本文介绍了一种自定义UINavigationController返回按钮的方法,通过子类化UINavigationController并在pushViewController方法中定制返回按钮,以实现代码复用并避免为每个视图控制器单独设置返回按钮。

104

被折叠的 条评论
为什么被折叠?



