HaOx
HaOx

Reputation: 1879

Background only on parts of UINavigationBar

I want to set background to the navigation bar, but only at the one that is rounded by red rectangle. I do not want it on the other two, where says "Menú" and "Titulo Menu".

enter image description here

I use this code in AppDelegate class:

UIImage *navBarImg = [UIImage imageNamed:@"fondo.png"];
[[UINavigationBar appearance] setBackgroundImage:navBarImg 
  forBarMetrics:UIBarMetricsDefault];

How can I do that? It is possible?

Thanks for any help

Upvotes: 0

Views: 47

Answers (1)

Berti
Berti

Reputation: 91

Do you initalize all of your NavBars in the storyboard? Or by code?

If you added them through the Storyboard, you can just link the red marked UINavBar to some Pointer in the code and just call:

[myNavbar setBackgroundImage:[UIImage imageNamed:navBarImg] 
           forBarMetrics:UIBarMetricsDefault];

So you don't change the Style of all NavBars, just the one you want.

Hope it works for you!

Upvotes: 3

Related Questions