In order to work with my colleagues, There are few steps to get a programmingly tabviewcontroller
adding the following steps in appdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//method
1.initiate window
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
2 initiate ViewController and tabbarcontroller
UIViewController *blankVC = [UIViewController new];
UIViewController *blankVC2 = [UIViewController new];
UIViewController *blankVC3 = [UIViewController new];
UIViewController *blankVC4 = [UIViewController new];
UIViewController *blankVC5 = [UIViewController new];
self.tabBarController = [[UITabBarController alloc]init];
3.adding VCs in Tabcontroller by NSarray
NSArray* controllerArray = [[NSArray alloc]initWithObjects:blankVC,blankVC2,blankVC3,blankVC4,blankVC5 ,nil];
self.tabBarController.viewControllers = controllerArray;
4.initiate tabBar
UITabBar *tabBar = self.tabBarController.tabBar;
[tabBar setTintColor: [UIColor colorWithRed:255.f/255.f green:135.f/255.f blue:5.f/255.f alpha:1]];
[tabBar setBackgroundColor:[UIColor grayColor]];
[self.tabBarController.tabBar setTranslucent:NO];
(5.set tabBar fonts Attribute)
NSDictionary *attributes=[NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor],NSForegroundColorAttributeName,[UIFont systemFontOfSize:14],NSFontAttributeName, nil];
[[UITabBarItem appearance] setTitleTextAttributes:attributes forState:UIControlStateNormal];
NSDictionary *attributesHL=[NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:255.f/255.f green:135.f/255.f blue:5.f/255.f alpha:1],NSForegroundColorAttributeName,[UIFont systemFontOfSize:14],NSFontAttributeName, nil];
[[UITabBarItem appearance] setTitleTextAttributes:attributesHL forState:UIControlStateHighlighted];
6.initiate tabbaritem and link them to tabBar
UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:0];
UIImage* tabBarItem2Image = [UIImage imageNamed:@"tab_icons_one"];
UIImage* tabBarItem2SelectedImage = [UIImage imageNamed:@"tab_icons_one_prs"];
(void)[tabBarItem2 initWithTitle:@"first" image:tabBarItem2Image selectedImage:tabBarItem2SelectedImage];
UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:1];
(void)[tabBarItem1 initWithTitle:@"" image:nil selectedImage:nil];
tabBarItem1.enabled = false;
UITabBarItem *tabBarItem3 = [tabBar.items objectAtIndex:2];
UIImage* tabBarItem3Image = [UIImage imageNamed:@"tab_icons_two"];
UIImage* tabBarItem3SelectedImage = [UIImage imageNamed:@"tab_icons_two_prs"];
(void)[tabBarItem3 initWithTitle:@"thrid" image:tabBarItem3Image selectedImage:tabBarItem3SelectedImage];
//blank one
UITabBarItem *tabBarItem4 = [tabBar.items objectAtIndex:3];
(void)[tabBarItem4 initWithTitle:@"" image:nil selectedImage:nil];
tabBarItem4.enabled = false;
UITabBarItem *tabBarItem5 = [tabBar.items objectAtIndex:4];
UIImage* tabBarItem5Image = [UIImage imageNamed:@"tab_icons_three"];
UIImage* tabBarItem5SelectedImage = [UIImage imageNamed:@"tab_icons_three_prs"];
(void)[tabBarItem5 initWithTitle:@"fifth image:tabBarItem5Image selectedImage:tabBarItem5SelectedImage];
(7.repositio tabbaritems)
tabBarItem5.titlePositionAdjustment=UIOffsetMake(-40, -3.0);
tabBarItem3.titlePositionAdjustment=UIOffsetMake(0, -3.0);
tabBarItem2.titlePositionAdjustment=UIOffsetMake(40, -3.0);
8.set tabBar target to any viewcontroller in this case
self.tabBarController.selectedIndex = 1;
9.set tabbarcontroller the rootviewcontroller
[self.window setRootViewController:self.tabBarController];
[self.window makeKeyAndVisible];
all in all my intent here is to set the second invisible viewcontroller as Home but not people not able to tab on it.
It is our requirement to do so, you may not use the structure like this. so use it weathly