If all you want is to give the tabs a "selected" and a "normal" background image (which include one half of the divider left and right) you could subclass UITabBarController and during viewDidLoad replace the UITabBar with UIButtons. It's pretty straight forward. The images are set as the background of the buttons. They contain 4px of the divider on the left and the right side.
I am using this with a storyboard so the self.tabBar.items array is already populated when viewDidLoad is called.
@interface MyTabBarController()
@property (nonatomic,strong) UIImage *selectedImage;
@property (nonatomic,strong) UIImage *normalImage;
@end
@implementation MyTabBarController
@synthesize selectedImage, normalImage;
- (void) viewDidLoad
{
[super viewDidLoad];
// set whichever view you want to start with
self.selectedIndex = 1;
self.tabBar.hidden=YES;
// those are the images used for the selected and not selected tabs
self.selectedImage = [[UIImage imageNamed:@"tabBarBackground_down.png"] stretchableImageWithLeftCapWidth:4 topCapHeight:0];
self.normalImage = [[UIImage imageNamed:@"tabBarBackground.png"] stretchableImageWithLeftCapWidth:4 topCapHeight:0];
CGFloat width = self.view.frame.size.width/[self.tabBar.items count];
for( int itemIndex=0; itemIndex<[self.tabBar.items count]; itemIndex++ )
{
UITabBarItem *item = [self.tabBar.items objectAtIndex:itemIndex];
// create a button
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
// configure the button to act as a tab
button.adjustsImageWhenHighlighted = NO;
[button setImage:item.image forState:UIControlStateNormal];
[button setBackgroundImage:self.selectedIndex==itemIndex?self.selectedImage:self.normalImage forState:UIControlStateNormal];
// this is used later to set the selectedIndex of the UITabBarController
button.tag = itemIndex;
// position the button in place of tab
CGFloat nextXStart = itemIndex+1==[self.tabBar.items count]?self.view.frame.size.width:rint(width*(itemIndex+1));
button.frame = CGRectMake(rint(width*itemIndex), self.view.frame.size.height-49, nextXStart-rint(width*itemIndex) , 49);
[self.view addSubview:button];
// add event to the button
[button addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchDown];
}
}
- (void) buttonClicked:(id)sender
{
UIButton *button = sender;
if( self.selectedIndex!=button.tag )
{
// select the tab and change the visible viewcontroller
self.selectedIndex = button.tag;
// reset all but the active buttons to have the normal image
for( UIView *subview in self.view.subviews )
{
if( subview!=sender && [subview isKindOfClass:[UIButton class]])
[((UIButton *)subview) setBackgroundImage:self.normalImage forState:UIControlStateNormal];
}
// set the selectedImage as background of the clicked button
[button setBackgroundImage:self.selectedImage forState:UIControlStateNormal];
}
}
@end