Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 7.1 issue - Tabbar resizing doesn't work

Since i updated to iOS 7.1 the resizing of the tab (to 74 pixels) that doesn't work anymore:

[[tabBarController.view.subviews objectAtIndex:0] setFrame:CGRectMake(0, 0, 320, screenSize.height-73)];
[tabBarController.tabBar setFrame:CGRectMake(0, screenSize.height-73, 320, 74)];

This code results in the tab being moved up, but with some empty space bellow.

As anyone a fix for that ?

like image 800
franck Avatar asked Mar 14 '14 15:03

franck


2 Answers

If you change the size of your UITabBar in the viewDidLayoutSubviews of your UITabBarController subclass, the resizing works under iOS 7 and 7.1. Take my code as an example:

- (void)viewDidLayoutSubviews
{
     CGFloat tabBarHeight = 39.0;
     CGRect frame = self.view.frame;
     self.tabBar.frame = CGRectMake(0, frame.size.height - tabBarHeight, frame.size.width, tabBarHeight);
}
like image 123
amb Avatar answered Nov 12 '22 21:11

amb


this is what i currently use, I have removed the image from the tab bar, then i added this bit of code to position the text, I think the second line is obsolete but i keep it anyway. the for statement places your text in the bar, so u can adjust modifying the -25 value, 30 being the size of my tab bar height. The rest of the bar is technically "hidden" under the screen.

self.tabBar.frame = CGRectMake(0, screenHeight - 30,  screenWidth, 30);
self.view.frame = CGRectMake(0, screenHeight - 30,  screenWidth, 30);

for (int i = 0; i < self.tabBar.items.count; i++)
{
    [[self.tabBar.items objectAtIndex:i] setTitlePositionAdjustment:UIOffsetMake(0, -25)];
}
like image 41
Pier-Luc Avatar answered Nov 12 '22 23:11

Pier-Luc