Reputation: 1922
I'm trying to implement FontAwesome's icons in my Xcode Project. I have put in the fontawesome.ttf
file into my project, and I am using code from this github to put them into the UIImageView
of my UIButton
: https://github.com/alexdrone/ios-fontawesome.
I am able to get the icons into my app by doing this sample code from the github Demo here:
FAImageView *imageView = [[FAImageView alloc] initWithFrame:CGRectMake(0.f, 0.f, 100.f, 100.f)];
imageView.image = nil;
[self.view addSubview:imageView];
UIImage *icon = [UIImage imageWithIcon:@"fa-github" backgroundColor:[UIColor purpleColor] iconColor:[UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:255] fontSize:50];
UIImageView *github = [[UIImageView alloc] initWithImage:icon];
CGRect rect = github.frame;
rect.origin.y += CGRectGetMaxY(imageView.frame);
github.frame = rect;
[self.view addSubview:github];
However, I'm trying to put a FontAwesome icon in a UIButton
's image view (which is in the storyboard connected to an IBOutlet
) with this code:
self.backOneSentenceButton.imageView.image = [UIImage imageWithIcon:@"fa-backward" backgroundColor:[UIColor blackColor] iconColor:[UIColor blackColor] andSize:self.backOneSentenceButton.bounds.size];
But the icon isn't showing up at all in the button, and it's just a plain white button. Is there anything I might be missing here? Or am I doing it completely wrong? Any help or advice would be appreciated. Thanks.
Upvotes: 0
Views: 1322
Reputation: 790
Just set class of image as your lib you have added.
Hope this could help.
Upvotes: 1