views:

4271

answers:

4

I've been trying to set up a custom background for the whole of my NavigationBar (not just the titleView) but have been struggling.

I found this thread

http://discussions.apple.com/thread.jspa?threadID=1649012&tstart=0

But am not sure how to implement the code snippet that is given. Is the code implemented as a new class? Also where do I instatiate the NavigationController as I have an application built with the NavigationView template so it is not done in my root controller as per the example

A: 

I managed to work it out thanks anyway guys, posted answer in original thread

tigermain
+6  A: 

You just have to overload drawRect like that :

@implementation UINavigationBar (CustomImage)
- (void)drawRect:(CGRect)rect {
    UIImage *image = [UIImage imageNamed: @"NavigationBar.png"];
    [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end
Lithium
A: 

hi,

i just found this blog entry, describing this topic very simple: http://web0.at/blog/?p=38

it helped me a lot, they use the "drawRect" method to get the customisation of the background.

d4rwin
+1  A: 

another solution

http://snipt.net/jonatasmiguel/tag/mac

Sijo