Custom navigation buttons of ios navigator

I'm having trouble creating a custom navigation bar like Uber app .

screenshot

I set the background image of the button:

UIImage *button44 = [[UIImage imageNamed:@"navButtonAdd"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)]; [[UIBarButtonItem appearance] setBackgroundImage:button44 forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; 

But if I delete the text from the button on the xcode interface, it will also disappear, and an inscription will appear on the right, which will again repeat my image.

screenshot

Does anyone know how I can fix this?

This is the image I'm trying to use as a button

screenshot

Thank you in advance

+4
source share
1 answer
 self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"button"]]]; [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"uberbar.png"] forBarMetrics:UIBarMetricsDefault]; 

If I'm not mistaken, you need a custom view of UIBarButtonItem. Thus, you can get the appearance proxy server, set the image for the controller or, conversely, configure the image directly. This add-on is a matter of photoshop graphics and the correctness of its size.

+2
source

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


All Articles