0

I need to change UITabBarItem's image and text position when it's highlighted. Is it possible?

Timur Bernikovich
  • 5,660
  • 4
  • 45
  • 58

1 Answers1

1

It's look like there is no way to change UITabBarItem's image's position. I just corrected my selected image to have about 15 pixels in button and corrected UITabBarItem's title's position on 15 in tabBar:didSelectItem: method of my custom UITabBarController:

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
    // If there is another selected item set default properties to it.
    for (int counter = 0; counter < [self.tabBar.items count]; counter++) {
        UITabBarItem *currentSelectedItem = [self.tabBar.items objectAtIndex:counter];
        [currentSelectedItem setTitlePositionAdjustment:UIOffsetMake(0, 0)];
    }

    // Set selected item.
    UITabBarItem *selectedItem = item;
    [selectedItem setTitlePositionAdjustment:UIOffsetMake(0, -15)];
}
Timur Bernikovich
  • 5,660
  • 4
  • 45
  • 58