Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

UITabBar color

Posted on 2014-09-05
3
192 Views
Last Modified: 2015-01-22
Hi guys,

I am trying to set the selected and unselected color for my UITabBar icons and text,

My code doesn't seem to be working what is the best solution, I have the following in the appdelegate

Note: the only thing thats not working is the unselected state.

UIImage *tabBarBackground = [UIImage imageNamed:@"TabBar.png"];
    
    [[UITabBar appearance] setBackgroundImage:tabBarBackground];
    
    [[UITabBar appearance] setTintColor:[UIColor blackColor]];
    [[UITabBar appearance] setSelectedImageTintColor:[UIColor blackColor]];
    
    
    [[UIView appearanceWhenContainedIn:[UITabBar class], nil] setTintColor:[UIColor redColor]];
    [[UITabBar appearance] setSelectedImageTintColor:[UIColor greenColor]];
    

Open in new window

0
Comment
Question by:john_yourspace
  • 2
3 Comments
 
LVL 19

Expert Comment

by:Shahan Ayyub
ID: 40313879
Did you try TabBar delegate functions ? e.g., didSelectItem ? Change the image for all button and then selected image of the button that tapped ?
0
 

Author Comment

by:john_yourspace
ID: 40313886
Do you have some sample code to try
0
 
LVL 19

Accepted Solution

by:
Shahan Ayyub earned 500 total points
ID: 40314412
Look at this thread. You have to use this delegate functions and assigned `delegate` property to call it at runtime. In this delegate you can iterate on `tabBar.items` and assigned an image to them. First assigned deselect image to all of them then the item passed in delegate function assigned it a selected image. Currently i don't have mac so can not give you an example code, but will try to give you soon.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Basics of Storyboard Storyboards were first introduced to developers in the release of iOS 5. They save the developer the trouble of designing each screen’s interface in a different file. The storyboard allows you to see the conceptual mockup o…
Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question