0

I have a tabbar with 5 tabs(0,1,2,3,4) at the bottom of the screen and they have different icons. What I am trying to achieve is for the 2nd tab I want a UIView on it and an image inside this UIView.

For this, I tried creating custom UITabBarItem class but I don't see any way I can add UIView in this custom class. Is there any way I can achieve this?

Hope you understand the problem.

Thanks in advance

George
  • 3,600
  • 2
  • 26
  • 36
  • can you plz post your code? if i understand your qus correctly do you wanna to remove & add 2nd tab bar item based on your data? – Dharma Jun 08 '17 at 11:47
  • I want to able to add UIView in tabbaritem and an Image inside this view. – George Jun 08 '17 at 11:48

1 Answers1

0

If you don't want to show one tab in specific condition then you should set viewcontrollers of tabbabcontroller something like,

  NSMutableArray *tabBarVcArr =  [self.tabBarController.viewControllers mutableCopy];

[tabBarVcArr removeObjectAtIndex:1];  // this will remove second tab 

self.tabBarController.viewControllers = tabBarVcArr;

if you want to add tab again then you can instantiate your tabbarcontroller from your storyboard !

That's it!! no need to subclass UITabBarButtonItem etc!

Ketan Parmar
  • 27,092
  • 9
  • 50
  • 75