Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS custom tabbar

I just started with iOS development and am just playing around atm.

I'm trying to transform the default tabbar buttons into something more custom.

After some looking around I found you can create custom states for every button, so I did:

UIImage *selectedImage0 = [UIImage imageNamed:@"first.png"];
UIImage *unselectedImage0 = [UIImage imageNamed:@"second.png"];

UITabBar *tabBar = self.tabBarController.tabBar;
UITabBarItem *item0 = [tabBar.items objectAtIndex:0];

[item0 setFinishedSelectedImage:selectedImage0 withFinishedUnselectedImage:unselectedImage0];

However, I can't get rid of the default button, it changes the image, but it doesn't change my entire button.

Is there something else I need to do?

UIViewController *viewController1 = [[FirstViewController alloc]     initWithNibName:@"FirstViewController" bundle:nil];
UIViewController *viewController2 = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];

self.tabBarController = [[UITabBarController alloc] init];    
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, nil];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];

UIImage *selectedImage0 = [UIImage imageNamed:@"first.png"];
UIImage *unselectedImage0 = [UIImage imageNamed:@"second.png"];

UITabBar *tabBar = self.tabBarController.tabBar;
UITabBarItem *item0 = [tabBar.items objectAtIndex:0];

[item0 setFinishedSelectedImage:selectedImage0 withFinishedUnselectedImage:unselectedImage0];
like image 958
woutr_be Avatar asked Dec 07 '22 15:12

woutr_be


1 Answers

Check the following Links(Most of the customization of the tab-bar controller)

  1. Implement a Custom Tab Bar
  2. Tabbar with custom colors
  3. Custom Tabbar diff. background
  4. How to Save User Customized Tab Order]
  5. RX -Tabbar controller
like image 190
NIKHIL Avatar answered Dec 11 '22 10:12

NIKHIL