I am trying to put an image in my UI. the Controllers
present as the UITabBarItem are UINavigationControllers
. When i am trying to put images, on them, the result is not looking good. I am getting only half images, and the images show no color.
the 3 images that i have used are .png images having dimensions 50X50.
here is the code that i have used
self.custCareVC = [[CustomerCareViewController alloc] initWithNibName:@"CustomerCareViewController_iPhone" bundle:NULL];
self.POController = [[PurchaeOrderViewController alloc] initWithNibName:@"PurchaeOrderViewController_iPhone" bundle:NULL];
self.accAndContactsController = [[AccountsAndContactsViewController alloc] initWithNibName:@"AccountsAndContactsViewController_iPhone" bundle:NULL];
self.customerCareNavController = [[UINavigationController alloc] initWithRootViewController:self.custCareVC];
self.customerCareNavController.title = @"Customer Service";
self.purchaseOrderNavController = [[UINavigationController alloc] initWithRootViewController:self.POController];
self.purchaseOrderNavController.title = @"PO";
self.accAndContactsNavController = [[UINavigationController alloc] initWithRootViewController:self.accAndContactsController];
self.accAndContactsNavController.title = @"Accounts And Contacts";
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:self.customerCareNavController, self.accAndContactsNavController, self.purchaseOrderNavController, nil];
UIImage *selectedImage0 = [UIImage imageNamed:@"cust_serv_bw_selected.png"];
UIImage *unselectedImage0 = [UIImage imageNamed:@"cust_serv_bw.png"];
UIImage *selectedImage1 = [UIImage imageNamed:@"contacts_bw_selected.png"];
UIImage *unselectedImage1 = [UIImage imageNamed:@"contacts_bw.png"];
UIImage *selectedImage2 = [UIImage imageNamed:@"po_bw_selected.png"];
UIImage *unselectedImage2 = [UIImage imageNamed:@"po_bw.png"];
UITabBar *tabBar = self.tabBarController.tabBar;
UITabBarItem *item0 = [tabBar.items objectAtIndex:0];
UITabBarItem *item1 = [tabBar.items objectAtIndex:1];
UITabBarItem *item2 = [tabBar.items objectAtIndex:2];
item0.image = unselectedImage0;
item0.selectedImage = selectedImage0;
item1.image = unselectedImage1;
item1.selectedImage = selectedImage1;
item2.image = unselectedImage2;
item2.selectedImage = selectedImage2;
self.tabBarController.selectedViewController = self.customerCareNavController;
How can i correct this. Why is this happening?