Question

I am working on building a mobile app to compliment a website and I need to mimic the icons used on the site. The icons are from FontAwesome and I want them to appear as my UITabBar Items. I have successfully installed the FontAwesome into my project and then I was able to add the icon into a label, but I can't figure out how to get the icon to render in my tab bar item.

The code I used to render the icon in the label:

self.label.font = [UIFont fontWithName:@"FontAwesome" size:12];
self.label.text = [NSString stringWithFormat:@"%@", @"\uf007"];

I have also tried typing in "\uf007" into the title of the icon, and then changing the font in my viewDidLoad method, but that did not work. Thank you for any help!

EDIT

My reputation is below 10 so the link to the image is: uitabbaritem

In the image above, I am manually typing in the code I want to show. If I change the font to FontAwesome, the text stays the same.

Was it helpful?

Solution

[[UITabBarItem appearance] setTitleTextAttributes:
 [NSDictionary dictionaryWithObjectsAndKeys:
  [UIColor blackColor], UITextAttributeTextColor, 
  [UIFont fontWithName:@"font" size:0.0], UITextAttributeFont, 
  nil] 
                                         forState:UIControlStateHighlighted];

Reference - iOS5 TabBar Fonts and Color

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top