I've been stuggeling to change the uitabbar icons and background so it will look just the way I want it. everytime I change the background color it shows the color but not solid as the specific color I'm giving. also the images I set up for the items become gray when running.
so I have a CV for start with a start button. button code:
- (IBAction)start:(id)sender {
UIStoryboard *storyBoard = [self storyboard];
Start *startViewController = [storyBoard instantiateViewControllerWithIdentifier:@"start"];
[self presentViewController:startViewController animated:NO completion:nil];}
as you can see it only send to the second VC which is the UITabBarController. in the appdelegate i tried:
Start *tabController = (Start *)self.window.rootViewController;
//tab1
UITabBar *tabBar = (UITabBar *)tabController.tabBar;
UITabBarItem *item1 = [tabBar.items objectAtIndex:0];
[item1 setImage:[[UIImage imageNamed:@"1.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
//tab2
UITabBarItem *item2 = [tabBar.items objectAtIndex:1];
[item2 setImage:[[UIImage imageNamed:@"2.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
//tab3
UITabBarItem *item3 = [tabBar.items objectAtIndex:2];
[item3 setImage:[[UIImage imageNamed:@"3.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
//tab4
UITabBarItem *item4 = [tabBar.items objectAtIndex:3];
[item4 setImage:[[UIImage imageNamed:@"4.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
but it didn't seem to work. I look a lot but all I could find is tutorial about setFinishedSelectedImage: withFinishedUnselectedImage:; which didn't really help cause it's deprecated. all I could do so far is setting the uitabbar from the interfacebuilder.
to change the color I simply changed the tint and the background color. also tried putting a uiimageview behind the uitabbar but it didn't seems to work either.
to costumizing a UITabBar ios7-ios8 use this code
UITabBarItem *item0 = [self.tabBar.items objectAtIndex:0];
UITabBarItem *item1 = [self.tabBar.items objectAtIndex:1];
UITabBarItem *item2 = [self.tabBar.items objectAtIndex:2];
UITabBarItem *item3 = [self.tabBar.items objectAtIndex:3];
item0.title = @"item0title";
item1.title = @"item1title";
item2.title=@"item2title";
item3.title=@"item3title";
[item0 setImage:[[UIImage imageNamed:@"imagename"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[item0 setSelectedImage:[[UIImage imageNamed:@"imagename"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[item1 setImage:[[UIImage imageNamed:@"imagename"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[item1 setSelectedImage:[[UIImage imageNamed:@"imagename"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[item2 setImage:[[UIImage imageNamed:@"imagename"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[item2 setSelectedImage:[[UIImage imageNamed:@"imagename"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[item3 setImage:[[UIImage imageNamed:@"imagename"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
[item3 setSelectedImage:[[UIImage imageNamed:@"imagename"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
//[[UITabBar appearance] setSelectedImageTintColor:[uicolor whitcolor]];
//[[UITabBar appearance] setBarTintColor:[UIColor yellowColor]];
//[[UITabBar appearance] setTintColor:[UIColor yellowColor]];
[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor yellowColor] }
forState:UIControlStateSelected];
[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor whiteColor] }
forState:UIControlStateNormal];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.