Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 5    Views: 225

Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
01/14/14 05:19 PM (11 years ago)

Change Color of Selected Tab

Hi All, I could not find the solution to this, how would I change the color of a selected tab on iOS. This code seems like it would do the trick: [[UITabBar appearance] setSelectedImageTintColor:[UIColor redColor]]; But it makes no difference, the tab bar highlight stays black. Does anyone have a fix? Jake
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
01/14/14 06:57 PM (11 years ago)
... tweaking one of the most basic but most obvious visual aspects of your app: the tint color. Everything colored blue in iOS 7 is based on the tint color of the app. On iOS 7, the tint color is used to indicate which items can be tapped; for example, the + and Edit buttons in the navigation bar and the disclosure buttons of the table view cells are all selectable. Tinting also highlights active items, such as the icon on the currently selected tab. The tint color is used throughout an app to make the distinction between active and non-active elements. Because the UI is intended to stay out of the user’s way in iOS 7, the use of a single color in your app has until now never been so important. The tint color is blue by default, but by changing this color you can immediately give your app its own unique style with very little effort. Views inherit the tint color from their parent views, so by setting the tintColor property on the app’s single UIWindow instance you effectively change the tint color for every view. To change just in one view, add into viewDidLoad: viewDidLoad in MapDetailViewController.m: self.view.tintColor = [UIColor whiteColor]; self.view.tintColor = [UIColor colorWithRed:140/255.0f green:70/255.0f blue:35/255.0f alpha:1.0f]; http://www.raywenderlich.com/49316/how-to-update-your-app-for-ios-7 Give that a try, let us know how you get along. -- Niraj
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
01/14/14 09:34 PM (11 years ago)
@Niraj: Thanks for posting the article. It seems as though they use self.view.tintColor, however in the BT3.0 project do you think this would be [self.navigationController.tabBar]? (I do not know, but this seems like a good guess) Jake
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
01/14/14 10:28 PM (11 years ago)
Going back through the article, you can also try this in the viewDidLoad: self.tabBarItem.selectedImage = [UIImage imageNamed:@"MyTabBarIcon-Selected"]; -- Niraj
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
01/14/14 10:33 PM (11 years ago)
@Niraj: Ok, so I tried to put this in the viewDidLoad: [self.tabBarController.tabBar setSelectedImageTintColor:[UIColor whiteColor]]; However, the selected image is still black when the app loads. It must be overridden somewhere, because the default color is blue, and it is being displayed as black. Do you know where it is overridden? Thanks, Jake
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
01/15/14 08:48 AM (11 years ago)
Ok: I have figured it out. It does not make much sense that self.window.tintColor only affects the tab bar. But your article was right. appDelegate.m - Around line 117 //the window tint color affects built in iOS7 icons in the navigation bar... if(floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1){ self.window.tintColor = [BT_color getColorFromHexString:@"#000000"]; } Jake
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.