K
K
Kirill Sidorov2011-11-17 13:02:35
iOS
Kirill Sidorov, 2011-11-17 13:02:35

Custom background for NavigationBar?

I created a project from the Master-Detail App template, now I can't make a custom background for the NavigationBar.
I tried:

  • create a subclass of UINaviration and draw in drawRect like this:
    UIImage *backgroundImage = [UIImage imageNamed:@&quot;navBarBg.png&quot;];<br/>
    [backgroundImage drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];<br/>

  • change backgroundColor, tintColor:
    [self.navigationController.view.backgroundColor: [UIColor colorWithPatternImage:...]];<br/>

  • I even tried to add a subview:
    UIImageView *backView = [ autorelease];<br/>
     [backView setFrame:CGRectMake(0, 0, 480, 44)];<br/>
     [self.navigationController.navigationBar addSubview:backView];<br/>
     [self.navigationController.navigationBar sendSubviewToBack:backView];<br/>


But nothing comes out ... Tell me, how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
An, 2011-12-09
@Flanker_4

Good afternoon.
There are a lot of solutions on the Internet, or rather in its English part.
stackoverflow.com/questions/704558/custom-uinavigationbar-background
foobarpig.com/iphone/uinavigationbar-with-solid-color-or-image-background.html
Here are just a few links.
But it is worth noting that the issue of customizing the Navigation Bar is rather controversial.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question