1,Podfile 里面添加:
pod 'FontAwesome+iOS', :git => 'https://github.com/alexdrone/ios-fontawesome'
2,info.plist文件里面添加
Fonts provided by application,如下:
FontAwesome.png
3,添加完之后需要用的地方引入,
两种方式:
(一)
#import "NSString+FontAwesome.h"
UILabel *label = [...];
label.font = [UIFont fontWithName:kFontAwesomeFamilyName size:20];
label.text = [NSString fontAwesomeIconStringForEnum:FAIconGithub];
//也可以这样写,两种写法一样
//label.text = [NSString fontAwesomeIconStringForIconIdentifier:@"fa-github"];
identifier 参考 http://fortawesome.github.io/Font-Awesome/icons
(二)
#import "UIImage+FontAwesome.h"
UIImage *github = [UIImage imageWithIcon:@"fa-github" backgroundColor:[UIColor purpleColor] iconColor:[UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:255] iconScale:2.f fontSize:20];
网友评论