I use UITabBarController
as a root view and app supports iOS 6 and above. Project class hierarchy is as below.
UITabBarController - tab1 - UINavigationController - UIViewController - UIViewController . . - tab2 - UINavigationController - UIViewController - UIViewController . . . - tab3 - UIViewController - tab4 - UIViewController
I used below code to change height of UITabBar
in one of the UIViewControllers (which is inside UINavigationController
) in above hierarchy.
CGRect tabbarFrame = self.tabBarController.tabBar.frame; tabbarFrame.size.height += 60; self.tabBarController.tabBar.frame = tabbarFrame;
But its not changing the height. UITabBar
is displayed with default height. Though logging its value prints changed value as shown below.
<UITabBar: 0xb528f60; frame = (0 431; 320 109); autoresize = W+TM; layer = <CALayer: 0xb529080>>
How can I change UITabBar
's height to achieve something like this:?
But, the Height of TabBar can be changed by setting SizeFactor property of TabBarSplitterControl. When SizeFactor changed, TabBar Height will be changed with the new value by multiplying the SystemInformation. HorizontalScrollBarHeight with SizeFactor.
To add a Tab Bar Controller to the Storyboard, select the 4 placeholders that we just created and the View Controller. Then, go to Editor, select Embed in and Tab Bar Controller. This will envelop all those scenes in a single Tab Bar Controller. Put the new Tab Bar Controller on top of the other controllers.
What's A Tab Bar Controller? A tab bar controller, of class UITabBarController, is a container view controller. It typically organizes 3-5 view controllers in a group. The user of your app can switch between view controllers by tapping one of the tabs in the tab bar at the bottom of the screen.
I faced this issue and I was able to solve it.
You have to add following code to your subclass of UITabBarController
class.
const CGFloat kBarHeight = 80; - (void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; CGRect tabFrame = self.tabBar.frame; //self.TabBar is IBOutlet of your TabBar tabFrame.size.height = kBarHeight; tabFrame.origin.y = self.view.frame.size.height - kBarHeight; self.tabBar.frame = tabFrame; }
Swift:
override func viewWillLayoutSubviews() { super.viewWillLayoutSubviews() tabBar.frame.size.height = kBarHeight tabBar.frame.origin.y = view.frame.height - kBarHeight }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With