Solved

UITabBar color

Posted on 2014-09-05
3
167 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
Comment Utility
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
Comment Utility
Do you have some sample code to try
0
 
LVL 19

Accepted Solution

by:
Shahan Ayyub earned 500 total points
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

CocoaPods is the best way to manage library dependencies in iOS and OS X projects. By using cocoa pods there is no need of downloading the code from github and copying to your project. There are plenty of open source libraries now available with C…
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
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.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now