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;
}
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);
It does well,but when I press the TabBarItem the size of item was changed
I know the issue is about the setting of imageInsets, but I don't know how to resize the TabBarItem without to set imageInsets.