Reputation: 60919
I have a UINavigationController that I'm creating programatically:
MessageTableViewController* homeStream = [[MessageTableViewController alloc] initWithNibName:@"MessageTableViewController" bundle:nil];
homeStream.fetchHomeStream = YES;
homeStream.title = @"Home";
UINavigationController* navBarController = [[UINavigationController alloc] initWithRootViewController:homeStream];
navBarController.tabBarItem.image = [UIImage imageNamed:@"hometab.png"];
[homeStream release];
I have a custom UINavigationBar called STNavigationBar. How can I use STNavigationBar instead of the default UINavigationBar that is part of the UINavigationController?
Upvotes: 0
Views: 799
Reputation: 60919
I ended up using the iOS5 UIKit appearance proxy:
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"header"] forBarMetrics:UIBarMetricsDefault];
No subclassing, or categories needed.
Upvotes: 3
Reputation: 974
Edit for future readers, the answer below does not work anymore on iOS 5.
You can't just set it to the existing instance, because UINavigationController has a readonly property for navigationBar. And I don't think subclassing a UINavigationController is what you want.
I recon the best way to do this is to create a category that extends a UINavigationBar, as discussed here.
Upvotes: 0