修改tabbar背景图片
方法1:
InBlock.gif //设置背景颜色,注意tabbar高度设置为49
InBlock.gif                CGRect frame = CGRectMake(0, 0, self.view.bounds.size.width, 49);
InBlock.gif                UIView *view = [[UIView alloc] initWithFrame:frame];
InBlock.gif                UIColor *color = [[UIColor alloc] initWithRed:255.0
InBlock.gif                                                                                                                                green:255.0
InBlock.gif                                                                                                                                    blue:255.0
InBlock.gif                                                                                                                                alpha:1.0];
InBlock.gif                [view setBackgroundColor:color];
InBlock.gif                [color release];
InBlock.gif                [[[self defaultTabBarController] tabBar] insertSubview:view atIndex:0];
InBlock.gif                [view release];

方法2:
InBlock.gif //设置图片为背景,注意tabbar高度设置为49
InBlock.gif                UIImageView *img = [[UIImageView alloc] initWithImage:[UIImage p_w_picpathNamed: @"backgroundImage.png"]];
InBlock.gif                img.frame = CGRectMake(0, 0,
InBlock.gif                                 self.defaultTabBarController.tabBar.frame.size.width,                                             self.defaultTabBarController.tabBar.frame.size.height);
InBlock.gif                img.contentMode = UIViewContentModeScaleToFill;
InBlock.gif                [[[self defaultTabBarController] tabBar] insertSubview:img atIndex:0];
InBlock.gif                [img release];


修改tabbar图片及背景图片

MyTabBarItem.h
InBlock.gif@ interface MyTabBarItem : UITabBarItem {
InBlock.gif@ private
InBlock.gif        
InBlock.gif        UIImageView *iconImageView;
InBlock.gif        UIImage *selectedIconImage, *iconImage;
InBlock.gif}
InBlock.gif
@property (nonatomic, retain) UIImage *selectedIconImage, *iconImage;
InBlock.gif
- ( void)setSelected:(BOOL)bo;
InBlock.gif- ( void)setIconImage:(UIImage *)p_w_picpath;
InBlock.gif- ( void)setSelectedIconImage:(UIImage *)p_w_picpath;
InBlock.gif
@end


MyTabBarItem.m
InBlock.gif #import "MyTabBarItem.h"
InBlock.gif

InBlock.gif@implementation MyTabBarItem
InBlock.gif
@synthesize selectedIconImage, iconImage;
InBlock.gif
- ( void)setSelected:(BOOL)bo
InBlock.gif{
InBlock.gif        UIView *_view = [self valueForKey: @"_view"];
InBlock.gif         if( bo )
InBlock.gif        {
InBlock.gif                iconImageView.frame = CGRectMake(0, 0, selectedIconImage.size.width/2, selectedIconImage.size.height/2);
InBlock.gif                iconImageView.center = CGPointMake(_view.frame.size.width/2, _view.frame.size.height/2);
InBlock.gif                iconImageView.p_w_picpath = selectedIconImage;
InBlock.gif        }
InBlock.gif         else
InBlock.gif        {
InBlock.gif                iconImageView.frame = CGRectMake(0, 0, iconImage.size.width/2, iconImage.size.height/2);
InBlock.gif                iconImageView.center = CGPointMake(_view.frame.size.width/2, _view.frame.size.height/2);
InBlock.gif                iconImageView.p_w_picpath = iconImage;                
InBlock.gif        }
InBlock.gif}
InBlock.gif
- ( void)awakeFromNib
InBlock.gif{
InBlock.gif        [super awakeFromNib];
InBlock.gif        iconImageView = [[[UIImageView alloc] init] autorelease];
InBlock.gif        [[self valueForKey: @"_view"] addSubview:iconImageView];
InBlock.gif}
InBlock.gif
- ( void)dealloc {
InBlock.gif        [selectedIconImage release];
InBlock.gif        [iconImage release];
InBlock.gif        [super dealloc];
InBlock.gif}
InBlock.gif
@end
 
- (void)viewDidLoad
InBlock.gif //add pictures of tab bar
InBlock.gif        NSArray *array = self.defaultTabBarController.tabBar.items;
InBlock.gif    
InBlock.gif        [[array objectAtIndex:0] setIconImage:[UIImage p_w_picpathNamed: @"btn_tab_recipes.png"]];
InBlock.gif        [[array objectAtIndex:0] setSelectedIconImage:[UIImage p_w_picpathNamed: @"btn_tab_recipes_selected.png"]];
InBlock.gif        [[array objectAtIndex:0] setSelected:YES];


- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController

InBlock.gif //set selected picture
InBlock.gif        NSArray *array = self.defaultTabBarController.tabBar.items;
InBlock.gif         for (MyTabBarItem *item in array) {
InBlock.gif                [item setSelected:NO];
InBlock.gif        }
InBlock.gif    
InBlock.gif        [[array objectAtIndex:defaultTabBarController.selectedIndex] setSelected:YES];