Subclassing UINavigationBar and setting background image for iOS 5

Question: I’ve just updated to iOS 5 and my iPhone applications are all working properly except the custom navigation bar. The background image is not drawn. I am not sure why. I am using Xcode 4.3 SDK and my code is attached. Answer: Since iOS 5 the UINavigationBar, UIToolbar, and UITabBar implementations have changed. The [drawRect:] method is not called on instances of these classes unless it is implemented in a subclass. Ergo, forget your previous Category solution. You must have a subclass like this:
@interface myNavigationBar : UINavigationBar <UINavigationBarDelegate> {
}
@end

@implementation myNavigationBar

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        // Initialization code
    }
    return self;
}

- (void)drawRect:(CGRect)rect
{
    // ColorSync manipulated image
    UIImage *imageBackground = [UIImage imageNamed: @"navback.png"];
    [imageBackground drawInRect: CGRectMake(0, 0, self.frame.size.width, self.frame.size.height) ];
}

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
   
}

- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated{
}

@end
Notes: 1. If you are getting
*** ImageIO - could not find ColorSync function 'ColorSyncProfileCreateWithName' and
*** ImageIO - could not find ColorSync function 'ColorSyncProfileCopyData'
error messages, your image is not prepared properly. Read this post for solution. 2. What to do with subclass? Open the xib where your Navigation Controller (UINavigationController) can be found. Select Identity Inspector and change class type from UINavigationBar to myNavigationBar. Save changes.