10

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];
Berry Blue
  • 15,330
  • 18
  • 62
  • 113
  • 1
    Please share screenshots and code where you are creating tab bar. – Sunil Sharma Oct 10 '17 at 10:14
  • As Sunil said, we need to see the code you are using to add the tab bar items to be able to help. I've done similar things before and they work just fine on iOS 11.0 so it could just be the way you are adding the tab bar item that is causing this. – xemacobra Oct 12 '17 at 15:20

1 Answers1

0

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

Bhavin Kansagara
  • 2,866
  • 1
  • 16
  • 20