Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 2    Views: 108

AppGuy30
Code is Art
Profile
Posts: 737
Reg: Oct 29, 2011
location unknow...
14,070
06/08/15 06:12 AM (9 years ago)

Any way to make the Tab bar have color icons?

Is there any way to modify the tab bar source code so it accepts color icons and displays them as such? Thanks.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
06/08/15 07:10 AM (9 years ago)
If you're talking Android, I have no clue. With respect to iOS... It would depend on how deep you want to go. Member Jeff (MGoBlue) a while back wrote a tutorial on creating a custom icon for the 'center' button of a tab bar. It's a little outdated, and the code may need some massaging, but the method is sound and if you don't mind a few extra objects and some math, you could create specific buttons for each location re-using some of his code: http://www.smugwimp.com/btMods/Tab_Bar_With_Custom_Center_Tab.pdf if you want to make 'apple spec' icons, I wrote a nifty how to using 'pixelmator': http://www.smugwimp.com/btMods/pixelTabIcons.pdf Also, I could be wrong, but I thought Chris' tabbar plugin allowed color icons... Hope this helps! Cheers! -- Smug
 
ictguy
Aspiring developer
Profile
Posts: 564
Reg: Jun 17, 2011
Mildura, Austra...
15,840
like
06/15/15 04:27 AM (9 years ago)
Some code that may help for iOS ... An example is here https://itunes.apple.com/us/app/swcg-wildlife-care/id993627300?mt=8 Obviously you will need to generate your own UIColor codes - http://uicolor.org Some of the code I used is below, you may need to try out a few statements one at time to see what difference it makes. // Go to the BT_tabBarController.m // Under the view did load method add the following // Set the "bar" tint color - does not work with ios 6, so use the if statement below! if ([self.tabBar respondsToSelector:@selector(setBarTintColor:)]) { [[UITabBar appearance] setBarTintColor:[UIColor colorWithRed:142/255.0f green:188/255.0f blue:229/255.0f alpha:1.0f]]; } else { // Set the "tint" color - needed for iOS 6 [[UITabBar appearance] setTintColor:[UIColor colorWithRed:142/255.0f green:188/255.0f blue:229/255.0f alpha:1.0f]]; } // Set the active selected tabbar images to dark blue [[UITabBar appearance] setSelectedImageTintColor:[UIColor colorWithRed:23/255.0f green:51/255.0f blue:134/255.0f alpha:1.0f]]; // Set the text color of the title names // blue for selected [[UITabBarItem appearance] setTitleTextAttributes:@{ UITextAttributeTextColor : [UIColor colorWithRed:0/255.0f green:97/255.0f blue:138/255.0f alpha:1.0f] } forState:UIControlStateSelected]; // white for unselected [[UITabBarItem appearance] setTitleTextAttributes:@{ UITextAttributeTextColor :[UIColor whiteColor] } forState:UIControlStateNormal]; // This works - set the tab bar text color in ios 6 // Unselected Text [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor whiteColor], UITextAttributeTextColor, nil] forState:UIControlStateNormal]; // Selected text UIColor *titleHighlightedColor = [UIColor colorWithRed:0/255.0 green:97/255.0 blue:138/255.0 alpha:1.0]; [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: titleHighlightedColor, UITextAttributeTextColor, nil] forState:UIControlStateHighlighted];
 

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.