0

My code here:

for (NSInteger i = 1; i<= 4 ; i ++) {

    UIViewController *VC = self.viewControllers[i-1];
    UIImage *itemImage = [[UIImage imageNamed:[self getTabBarItemImageNameFromIndex:i selected:NO]] imageWithRenderingMode:UIImageRenderingModeAutomatic];

    UIImage *itemImageSelected = [[UIImage imageNamed:[self getTabBarItemImageNameFromIndex:i selected:YES]]imageWithRenderingMode:UIImageRenderingModeAutomatic];

    UITabBarItem *item = [[UITabBarItem alloc]initWithTitle:[self getTabBarItemTitleWithIndex:i] image:itemImage selectedImage:itemImageSelected];

    item.tag = i-1;
    VC.tabBarItem = item;
}

First I run : enter image description here

I want to shrink the UITabBarItem size, the original size of picture is 36 × 36 pixels.

Then I add these code:

       item.imageInsets = UIEdgeInsetsMake(3, 3, 3, 3);

enter image description here

It does well,but when I press the TabBarItem the size of item was changed enter image description here

I know the issue is about the setting of imageInsets, but I don't know how to resize the TabBarItem without to set imageInsets.

ImWH
  • 820
  • 1
  • 7
  • 20

1 Answers1

0

I don't think that the standard UITabBar control is very customizable. I would recommend you create your own custom tab bar which fits your need, or use something like UISegmentedControl which is quite customizable.

Have a look at these threads for reference:

how to resize iphone tab bar in xcode?

How do I resize the tab bar items in Xcode 4.3.1?

Community
  • 1
  • 1
Gurtej Singh
  • 3,244
  • 1
  • 14
  • 27