No se puede personalizar la barra de pestañas en iOS5

I have a tab in iOS 5 and wish to have a image for the TabBarButton for the selected and on not-selected states. Here is the code:

 BOOL isIOS5 = [[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0;

        //[tabBarController.tabBar setBackgroundImage:[UIImage imageNamed:@"Tab-bg"]];
       // [tabBarController.tabBar setSelectionIndicatorImage:[UIImage imageNamed:@"Cell-bg"]];

         [[tabBarController.tabBar.items objectAtIndex:0] setFinishedSelectedImage:[UIImage imageNamed:@"list-menu-selected"] withFinishedUnselectedImage:[UIImage imageNamed:@"list-menu"]];
        [[tabBarController.tabBar.items objectAtIndex:1] setFinishedSelectedImage:[UIImage imageNamed:@"gallery-menu-selected"] withFinishedUnselectedImage:[UIImage imageNamed:@"gallery-menu"]];
        [[tabBarController.tabBar.items objectAtIndex:2] setFinishedSelectedImage:[UIImage imageNamed:@"map-menu-selected"] withFinishedUnselectedImage:[UIImage imageNamed:@"map-menu"]];
        [[tabBarController.tabBar.items objectAtIndex:3] setFinishedSelectedImage:[UIImage imageNamed:@"submit-menu-selected"] withFinishedUnselectedImage:[UIImage imageNamed:@"submit-menu"]];
        [[tabBarController.tabBar.items objectAtIndex:4] setFinishedSelectedImage:[UIImage imageNamed:@"search-menu-selected"] withFinishedUnselectedImage:[UIImage imageNamed:@"search-menu"]];

i.e. the images are 44px height for non-retina display so they should be enough to fill the space

The problem is that the images dont't go from top to bottom: there remains some space not filled at the bottom of the tabbar. Has anyone ever had this problem?

preguntado el 09 de marzo de 12 a las 14:03

2 Respuestas

Respondido 05 Abr '12, 14:04

If you're already checking for specific cases like iOS 5, might be easiest just to create images that match the exact pixel height of the bar already. Alternatively you can look at what properties you can set on the tabBar.item itself.

respondido 09 mar '12, 14:03

isn't 44px the height of the tab bar? - Alex

I think it actually varies according to what version it is (at least I recall that, from somewhere). You may be able to get the properties by asking the item for its bounds/frame. - scott corscadden

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.