Reputation: 161
I have a UITabBarController holding 4 controllers (navigation controllers). Now i would like change the frames of all 4 controller views, so what is the best practice for this ?
Note: UITabBarController will always reset the frames of its container views, since it will try to fit them to its container view bounds.
Upvotes: 1
Views: 1921
Reputation: 161
I solved my problem and maintained the native UITabBarController :
Since the UITabBarController will force the view controllers' size to its bounds, I dynamically changed the UITabBar origin.y ( tabBar.origin.y -= reduced size
) and size.height tabBar.size.height += reduced size
) so that the container frame for the viewcontrollers is forced to get smaller.
And than, to preserve the casual tab bar design, for each UITabBarItem in the tabBar, i pushed the imageInset.
This way there is no need to force change frames of multiple viewControllers views in tabBarController through observers for layer change or any other similar methods.
Upvotes: 1
Reputation: 173
You can do it by creating custom tabbar controller.
Please check below screenshot for how to create custom tabbar to fulfil your requirement.
Once you create tabbar this way and change frame size of container it will look like as i have shown in next screen shot. You can change container frame size through coding as per your convenient.
Upvotes: 1