I could't set the colour of the icon
burakkilic opened this issue · 2 comments
burakkilic commented
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?
PrideChung commented
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.
burakkilic commented
I am very sorry, I did a stupid mistake. Now all are ok. Thank you.