ios-fontawesome icon indicating copy to clipboard operation
ios-fontawesome copied to clipboard

How to add the font awesome image to a tab bar item image?

Open jas54 opened this issue 12 years ago • 5 comments

From the documentation, there are two options to use font awesome image[ via label strings and FAImageView]. But how to use the font awesome image to a UIImage? For tab bar items with title, how can i set the font awesome image as the tab bar item image?

jas54 avatar Dec 05 '13 08:12 jas54

@jas54: I've also tried to use fontawesome to acheive this in my iOS app and I haven't managed yet. Did you solve it eventually?

artisani avatar Apr 07 '14 13:04 artisani

Try this project: http://nschum.github.io/FontAwesomeIconFactory/

For specific on how to create a tabbar image, refer to this file:

https://github.com/nschum/FontAwesomeIconFactory/blob/master/FontAwesomeIconFactoryDemo/FontAwesomeIconFactoryDemo/TabBarController.m

jimmychu0807 avatar May 15 '14 23:05 jimmychu0807

I have saw a API "(UIImage_)imageWithIcon:(NSString_)identifier backgroundColor:(UIColor_)bgColor iconColor:(UIColor_)iconColor iconScale:(CGFloat)scale andSize:(CGSize)size;" in the UIImage+FontAwesome.h But if i use it through swift it will also post a compiler error

UIImage(icon: <String!>, backgroundColor: <UIColor!>, iconColor: <UIColor!>, iconScale: <CGFloat>, andSize: <CGSize>)

Could you tell me how to use this API? Thanks!

cloud-hot avatar Jan 04 '15 12:01 cloud-hot

I tried this and seemed to work just fine! But only tried for TabBarItems. It's either a fix or just a work around. I`m using Xcode 6.3 and get it working on real device, besides simulator.

Take a look.

UIImage *iconDefault  = [UIImage imageWithIcon:@"fa-github" backgroundColor:[UIColor clearColor] iconColor:[UIColor whiteColor] andSize:CGSizeMake(32, 32)];
UIImage *iconSelected = [UIImage imageWithIcon:@"fa-github" backgroundColor:[UIColor clearColor] iconColor:[UIColor blueColor] andSize:CGSizeMake(32, 32)];

UITabBarItem *tabItem = [_tabBar.items objectAtIndex:0];
tabItem.image         = [iconDefault imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
tabItem.selectedImage = [iconSelected imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];];

mzamoras avatar Jun 07 '15 06:06 mzamoras

You can check this https://github.com/aqua30/FontAwesomeTab . It lets you add font awesome images in the tabs icon. May be its helpful to you.

aqua30 avatar Aug 13 '15 03:08 aqua30