2

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.

farberjd
  • 94
  • 9
  • this link may help you.. http://stackoverflow.com/questions/11221333/how-to-change-the-font-size-of-the-tab-bar-controller-item-name – RAJA Mar 26 '14 at 03:09
  • How did you install FontAwesome into your iOS project? Did you use ios-fontawesome or FontAwesomeKit libraries? – aksh1t Mar 26 '14 at 05:49
  • I downloaded the package from the FontAwesome site, then imported it into my project, added the TTF and OTF to the .PLIST. And made sure it was in the copy resources to bundle section. – farberjd Mar 26 '14 at 12:18

1 Answers1

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

Reference - iOS5 TabBar Fonts and Color

Community
  • 1
  • 1
RAJA
  • 1,214
  • 10
  • 13
  • Changing the appearance is one part of the solution, but not the entire thing. In order to set the font icon, FontAwesome uses codes, like '\f007'. I can change the Font Type, but the code does not register as an icon regardless. I don't know how to do both at the same time. – farberjd Mar 26 '14 at 12:20