1

Since iOS 5 Apple provided an API to customise the UITabBarItems in the UITabBar object. I am refering specifically to the following selector:

setFinishedSelectedImage:withFinishedUnselectedImage:

It all works great for regular buttons but I can't seem to customise the "More" button to match the style of the other ones. This is what I am doing:

tabBarController.viewControllers = tabBarControllerArray;
    tabBarController.moreNavigationController.navigationBar.tintColor = [UIColor blackColor];
    UITabBarItem *more = tabBarController.moreNavigationController.tabBarItem;
     if ([more respondsToSelector:@selector(setFinishedSelectedImage:withFinishedUnselectedImage:)]){
        [more setFinishedSelectedImage:[UIImage imageNamed:@"BarIcon-More.png"]
           withFinishedUnselectedImage:[UIImage imageNamed:@"BarIcon-More.png"]
         ];
    } else {
        more.image = [UIImage imageNamed:@"BarIcon-More.png"];
    }

The result is as follows, it doesn't pick-up my custom More image.

Inactive more button Ugly active more button

I have seen many hacks to replace the more button but there's got to be a better way of doing this right?

ronalchn
  • 12,225
  • 10
  • 51
  • 61
pierrephi
  • 101
  • 1
  • 6

1 Answers1

8

The solution was silly.

I assumed the UITabBarItems in the moreNavigationController was readonly and it wasn't. So simply doing the following:

tabBarController.moreNavigationController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"More" image:[UIImage imageNamed:@"BarIcon-More.png"] tag:0];

And the same customization code as above works.

Mihai Iorga
  • 39,330
  • 16
  • 106
  • 107
pierrephi
  • 101
  • 1
  • 6
  • 4
    This does not seem to work on iOS 6. Setting the `tabBarItem` property on the more controller does nothing. I can step over the assignment line in the debugger checking before and after and it doesn't change. Any other solutions? – Tom Hamming Jun 20 '13 at 20:05