Tim Bernikovich
Tim Bernikovich

Reputation: 5945

How to change UITabBarItem position?

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

Upvotes: 0

Views: 3119

Answers (1)

Tim Bernikovich
Tim Bernikovich

Reputation: 5945

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)];
}

Upvotes: 1

Related Questions