PrideChung / FontAwesomeKit

Icon font library for iOS. Currently supports Font-Awesome, Foundation icons, Zocial, and ionicons.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I could't set the colour of the icon

burakkilic opened this issue · comments

Hello;

I want to set foreground of the icon like this:

    FAKFontAwesome *infoIcon = [FAKFontAwesome infoIconWithSize:70];
UIColor* color = [Helper color:@"#ff0043" withAlpha:1.0];
[infoIcon addAttribute:NSForegroundColorAttributeName value:color];
UIImage *iconImage = [infoIcon imageWithSize:CGSizeMake(90, 90)];
[self.infoButton setImage:iconImage forState:UIControlStateNormal];

My helper function takes hex code of the color and returns a UIColor.

+ (UIColor*)color:(NSString*)colorCode withAlpha:(float)alpha{
if(!colorCode)
    return [UIColor blackColor];
unsigned result = 0;
NSScanner *scanner = [NSScanner scannerWithString:colorCode];
[scanner setScanLocation:1]; // bypass '#' character
[scanner scanHexInt:&result];
return [UIColor colorWithHex:result alpha:alpha];
}

But icon is always black. Where am I wrong?

Try to pinpoint your problem first. Assign [UIColor redColor] to the icon and see if it turn red. If it do turn red, then the problem is in your helper function.

I am very sorry, I did a stupid mistake. Now all are ok. Thank you.