The space between custom UITabBar and ViewController

I took a regular UITabBar and changed its background image to a custom one that has a lower height, so I changed the height to frame . First, I got an empty space under the tab bar. so I changed the origin value for frame . But now the empty space has risen above the tab bar, and this is the result:

space above tab bar

And this is the code declaring the tab bar in AppDelegate:

 self.tabContoller = [[UITabBarController alloc] init]; //customizing the tabbar UIImage * tabBackgroundImage = [UIImage imageNamed:@"tabBarBg.png"]; self.tabContoller.tabBar.backgroundColor = [UIColor colorWithRed:245.f/255.f green:245.f/255.f blue:245.f/255.f alpha:255.f/255.f]; self.tabContoller.tabBar.backgroundImage = tabBackgroundImage; //setting the tabbar height to the correct height of the image CGRect tabR = self.tabContoller.tabBar.frame; CGFloat diff = tabR.size.height - tabBackgroundImage.size.height; tabR.size.height = tabBackgroundImage.size.height; tabR.origin.y += diff; self.tabContoller.tabBar.frame = tabR; 

I suppose the problem is that the ViewController extends over a constant space, which is the height of the regular tab bar. Is there any way to change it?

+6
source share
4 answers

Change the UITabBarController sub-selections to a full-sized frame, this worked for me:

 [[yourTabBarController.view.subviews objectAtIndex:0] setFrame:CGRectMake(0, 0, 320, 480)]; 
+7
source

Try creating your own class that extends from UITabBar and use this function:

 - (CGSize)sizeThatFits:(CGSize)size { CGSize auxSize = size; auxSize.height = 54; // Put here the new height you want and that it return auxSize; } 

This will resize the UITabBar to the desired size. Simple and easy.

+7
source

If changing a frame such as @JoaT does not work, make sure that the correct auto-mask is set in the view controller's view.

This link fooobar.com/questions/113556 / ... may be helpful.

0
source

I tried to change the height and the beginning of the tab, for me it worked correctly. You can try increasing the height of your view manager.

0
source

Source: https://habr.com/ru/post/916555/


All Articles