Search code examples
iosxcodeuitabbarcontrolleruitabbar

Xcode 7 - UITabBarController changes content size


I've looked for a solution for changing UITabBarController's content size but not success.

Fortunately, today, I've found a way to do that. So, I wrote this article to public it to others (demo included). Hope it's useful for you. This is demo

In there, I've created a custom tabbar and changed its content view which contains your viewcontrollers.

Core function is re-layout UITransitionView in UITabBarController by follwing

-(void) viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];

    [tabBarBtnContainer invalidateIntrinsicContentSize];

    CGRect tabFrame = self.tabBar.frame;
    tabFrame.origin.y = self.view.frame.origin.y + 20;
    tabBarBtnContainer.frame = tabFrame;

    UIView *transitionView = self.view.subviews[0];
    transitionView.frame = CGRectMake(0, 70, self.view.frame.size.width,   
    self.view.frame.size.height - 70);
}

Solution

  • I've found the solution and wrote a demo here