Is there a way to globally change the title of all buttons on the navigation bar to “Back”,

Difficult to change it in all view controllers

Can I change it globally?

+6
source share
1 answer

What you can use is a category:

UINavigationItem + MyBackButton.h

@interface UINavigationItem (MyBackButton) @end 

UINavigationItem + MyBackButton.m

 #import "UINavigationItem+MyBackButton.h" @implementation UINavigationItem (MyBackButton) -(UIBarButtonItem*)backBarButtonItem { UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle: @"Back Button Text" style: UIBarButtonItemStyleBordered target: nil action: nil]; return [backButton autorelease]; } @end 

Add two projects to the project, and you're done. To be more efficient with ivar and lazy workload, should be added here.

+11
source

Source: https://habr.com/ru/post/911295/


All Articles