IOS custom image for navigation

I am trying to execute the following code in viewDidLoad {} to force out the custom "home" button, where the back button in the navigation controller is for two kinds.

UIImage *image1 = [UIImage imageNamed:@"btn-home-hd.png"]; [[UIBarButtonItem appearance] setBackButtonBackgroundImage:image1 forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; 

The problem is that the word "Back" still appears under the new image. The image is a house with a lilla, so we just want this image to appear, nothing under it. I tried putting blank space for the back button for this particular view in the storyboard

I see a lot of articles in it with this code, but no one mentions that the word "back" still appears ... why? Should this code be upstream in some init somewhere?

+4
source share
1 answer

I don’t know if this is the recommended strategy, but the way I solved it is to move the text overs. For instance.

 [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(-100, -100) forBarMetrics:UIBarMetricsDefault]; 
+2
source

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


All Articles