UITabBar背景替换
//---- For providing background image to tabbar UITabBar*tabBar =[tabBarController tabBar]; if([tabBar respondsToSelector:@selector(setBackgroundImage:)]){ // ios 5 code here [tabBar setBackgroundImage:[UIImage imageNamed:@"image.png"]]; } else{ // ios 4 code here CGRect frame =CGRectMake(0,0,480,49); UIView*tabbg_view =[[UIView alloc] initWithFrame:frame]; UIImage*tabbag_image =[UIImage imageNamed:@"image.png"]; UIColor*tabbg_color =[[UIColor alloc] initWithPatternImage:tabbag_image]; tabbg_view.backgroundColor = tabbg_color; [tabBar insertSubview:tabbg_view atIndex:0]; }