I'm using the font awesome resource for the UI of my iPhone application : FontAwesome
I have used it within my app screens like follows :
Phone.font = [UIFont fontWithName:kFontAwesomeFamilyName size:40];
Phone.text = [NSString fontAwesomeIconStringForIconIdentifier:@"fa-phone"];
But now I want to use it in the tab bar items of my tab bar controller i.e I want to set the icons of the tab bar to font awesome elements. How can this be done?
You can download fonts from the App Store app , then use them in documents you create on iPhone. After you download an app containing fonts from the App Store, open the app to install the fonts. To manage installed fonts, go to Settings > General, then tap Fonts.
To do this, add the key "Fonts provided by application" to Info. plist (the raw key name is UIAppFonts ). Xcode creates an array value for the key; add the name of the font file as an item of the array. Be sure to include the file extension as part of the name.
As per: How to change the Color of text in UITabBarItem in iOS 5
It looks like the solution may be sending the message to the appearance proxy, instead of one item:
[[UITabBarItem appearance] setTitleTextAttributes:@{
NSFontAttributeName:[UIFont fontWithName:@"AmericanTypewriter" size:20.0f]
} forState:UIControlStateNormal];
here is some more reference
how-to-change-the-color-of-text-in-uitabbaritem-in-ios-5
ios5-tabbar-fonts-and-color
Swift version:
UITabBarItem.appearance().setTitleTextAttributes(
[NSFontAttributeName: UIFont(name:"Ubuntu", size:11)!,
NSForegroundColorAttributeName: UIColor(rgb: 0x929292)],
forState: .Normal)
Swift 3
UITabBarItem.appearance().setTitleTextAttributes([NSFontAttributeName: UIFont(name:"Latio-Regular", size:14)!, NSForegroundColorAttributeName: UIColor.white], for: .normal)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With