Reputation: 171
I am using Xcode 8.1, on that when I uses TabBarViewController, it doesn't shows separate buttons for each tab, I want to add each Tab's specific image and title.
Following is the screenShot. My Problem is very Simple, I only want to Add Icons and titles to each Tab.
I am beginner. Any Idea will be Appreciated.
Upvotes: 1
Views: 1242
Reputation: 39
I'm using XCode 8.2.1, but the procedure should be similar to XCode 8.1
Steps to add image into tab 1. In your storyboard, drag a TabBarController from the palette, it comes with 2 default ViewController
In case You want to know how to manually link those ViewController together.
Upvotes: 1
Reputation: 1004
If I understand correctly and you are trying to customize the button icons in the tapbar, then you can do it programmatically using this code for each tapbar button index:
UITabBarController *myTabBar = [[UITabBarController alloc] init];
UITabBarItem *tabButton1 = [myTabBar.items objectAtIndex:0];
[tabButton1 setSelectedImage:[UIImage imageNamed:@"selected_image"]];
tabButton1.selectedImage = [[UIImage imageNamed:@"selected_image"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
tabButton1.image = [[UIImage imageNamed:@"unselected_image"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
tabButton1.title = @"Button 1 title";
NSArray *arrayViewControllers = [NSArray viewController1, viewController2, viewController3, nil];
[myTabBar setViewControllers:arrayViewControllers animated:NO];
Alternatively, you can set the image in the storyboard but keep in mind that the image alpha channel will be used to generate the select/unselect color tonality. That sometime lead to strange effects.
Upvotes: 0