Customizing UINavigationBar as in Fox news iPhone app

How can the UINavigationBar customizations be done? Is it using subclassing or categories?

I am interested in 2 aspects:

  1. Adding an image to the NavBar (like the FOXNEWS logo)
  2. Customizing the back button to "Shows". (the back button usually takes the title of the previous view in the stack, but there is no title in previous view.)

Thanks in advance for any help


For the Fox News app it looks like they just set the tint color of the navigation bar. As for the Fox News logo, it's probably just an image view on the title view of the navigation bar. This code goes into a view controller's viewDidLoad method:

[self.navigationController.navigationBar setTintColor:/* Custom color here */];

UIImageView *logoView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo"]];
[self.navigationItem setTitleView:logoView];
[logoView release];

To customize the back button you need to place this in the viewDidLoad method of the previous view controller (i.e. the one that this button leads back to):

UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Shows"
    style:UIBarButtonItemStyleBordered target:nil action:nil];
[self.navigationItem setBackBarButtonItem:backButton];
[backButton release];

If you want to use a totally custom background image for your application's navigation bar, you need to create a custom UINavigationBar category and draw the image within its drawRect: method. Something like this:

@implementation UINavigationBar (UINavigationBarBackgroundImage)

- (void)drawRect:(CGRect)rect
    [[UIImage imageNamed:@"navigation-bar"] drawInRect:rect];

    // Optionally you can set the tintColor here to go with the background


Need Your Help

Sampling from a texture which is also a render target

opengl directx render textures sampling

I know this technically isn't supported (and as far as I can tell it's undefined behavior) but is it really a fatally horrible thing to sample from a texture which is also being written to? Insert Into query local database (acess) database ms-access insert-into

I am not very good at running sql queries to a local database - Microsoft Access. I am trying to write a code where when a user register their details, it insert it into the database. I have wrote...