I use Xcode 4.3.2 and create an empty project based on "Master-Detail Application" Template. When I try to change the default navigation bar's appearance by code below, nothing happened, the drawRect function is never called.
#import "AppDelegate.h"
@implementation UINavigationBar (UINavigationBarCustomDraw)
- (void)drawRect:(CGRect)rect
{
NSLog(@"redraw");
[[UIImage imageNamed:@"NavBar.png"] drawInRect:rect];
self.topItem.titleView = [[UIView alloc] init];
self.tintColor = [UIColor colorWithRed:0.6745098 green:0.6745098 blue:0.6745098 alpha:1.0];
}
@end
@implementation AppDelegate
...
I know in iOS 5.x user can change UI's appearance by more easier ways, like
[[UINavigationBar appearance] setBackgroundImage:img
forBarMetrics:UIBarMetricsDefault];
But I just wonder why drawRect is not called, anyone can explain?