ask123
ask123

Reputation: 217

How to add tab bar programatically

I hidden my first tab bar,and now i want to add another tab bar in my next view.Please help me in this to write the code programatically

Upvotes: 0

Views: 925

Answers (1)

Vasu Ashok
Vasu Ashok

Reputation: 1413

UITabBarController *tabView=[[UITabBarController alloc] init];
tabView.view.frame=CGRectMake(0,0,screenRect.size.width, screenRect.size.height);
NSMutableArray *arrToAddView =[[NSMutableArray alloc]init];//array to store tab's view 

    for (int i=0;i<5;i++) 
    {
UIViewController *viewForTab = [[UIViewController alloc] init];
viewForTab.view.backgroundColor = [UIColor whiteColor];
[arrToAddView addObject:viewForTab];

    }           
[tabView setViewControllers:arrToAddView];
[self.view addSubview:tabView.view];

Upvotes: 3

Related Questions