在 iOS5 SDK 中原来设置 NavgationBar 背景的方法不能用了.

// disabeld in iOS5
@implementation UINavigationBar (NavgationBackground)
-(void)drawRect:(CGRect)rect {
    [[UIImage imageNamed:@"Navbar_bg.png"] drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end

@implementation UIToolbar (CustomImage)
- (void)drawRect:(CGRect)rect {
    [[UIImage imageNamed:@"toolbar_bg.png"] drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}
@end

iOS5 中的方法为

#pragma mark - set NavgationBar toolbar background
- (void)setNavgationBarBg:(UINavigationBar *)navbar
{
        UIImage * TitleBarImage = [UIImage imageNamed:@"Navbar_bg.png"];
        if([navbar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)])
        {
            [navbar setBackgroundImage:TitleBarImage forBarMetrics:UIBarMetricsDefault];
        }
}

- (void)setToolbarBg:(UIToolbar *)toolbar
{
    UIImage * toolbarImage = [UIImage imageNamed:@"toolbar_bg.png"];
    if ([toolbar respondsToSelector:@selector(setBackgroundImage:forToolbarPosition:barMetrics:)])
        [toolbar setBackgroundImage:toolbarImage forToolbarPosition:UIToolbarPositionBottom barMetrics:UIBarMetricsDefault];
}