0

当它突出显示时,我需要更改 UITabBarItem 的图像和文本位置。可能吗?

4

1 回答 1

1

看起来没有办法改变 UITabBarItem 的图像位置。我刚刚将我选择的图像更正为按钮中有大约 15 个像素,并更正了 UITabBarItem 在 tabBar 中 15 的标题位置:didSelectItem:我的自定义 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)];
}
于 2013-07-28T15:22:54.503 回答