UITabBarItem in landscape UITabBar in iOS 11

Viewed 1305

I'm programmatically adding tab bar items to a tab bar however when the tab bar is in landscape mode the tab bar items don't change to the new landscape style with the icon on the left and text on the right. How do I update the style of my tab bar items when the tab bar is in landscape mode for iOS 11?

Here is some code as requested.

UITabBar *tabBar = [UITabBar new];
NSInteger tag = 0;
NSMutableArray<UITabBarItem *> *items = [NSMutableArray new];
for(UIViewController *viewController in viewControllers)
{
    NSString *title = viewController.title;
    UIImage *image = [UIImage imageNamed:title];
    UITabBarItem *tab = [[UITabBarItem alloc] initWithTitle:title image:image tag:tag++];
    [items addObject:tab];
}

tabBar.items = items;
[self.view addSubview:tabBar];
1 Answers

It should work automatically when changing the orientation to landscape, I tried and it is working in Xcode 9.0, No additional code required to be done when you use storyboard based TabBar Controller or your custom TabBar Controller.

While googling I found that some one reported the same issue in one of the library Here

They fixed the issue by setting up the frames for label and image while orientation changes. so, please have a look here if that can be helpful. https://github.com/eggswift/ESTabBarController

Related