iconfont
从字面上就能理解它就是字体,让开发者像使用字体一样使用图标
获取iconfont
下载.ttf文件
点击我的项目下载,把相应的.ttf文件下载下来。


使用.ttf图标
参考了简书中文章在iOS开发中使用iconfont图标中iconfont的使用方法,做了一个封装,代码可以通过下载Demo来获取。把TBIconFont文件夹中的6个文件拖到你工程中,就像添加三方库一样,加进来就好了。
在APPDelegate中添加.ttf文件(初始化)
[TBCityIconFont setFontName:@"iconfont"];
程序中加载图标
//图标编码是,需要转成\U0000e600
self.testImageView.image = [UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e600", 30, [UIColor redColor])];
[self.testBtn setImage:[UIImage iconWithInfo:TBCityIconInfoMake(@"\U0000e604", 30, [UIColor redColor])] forState:UIControlStateNormal];
网友评论