写在前面
iconfont技术是将图标(icon)转换为字体(font),在iOS开发中可以减少App的体积。这里以阿里巴巴的iconfont为例。
iconfont的使用
- 在iconfont网站选中需要的图标,下载代码,解压缩文件包
-
在Xcode工程中添加ttf字符集imageimage
-
在plist文件中添加相应字段image
-
通过文件包中的html文件查看图标的Unicode编码image
- 添加label
//初始化label
UILabel *iconfontLabel = [[UILabel alloc] initWithFrame:CGRectMake(150, 100, 200, 200)];
//字体设置为iconfont
iconfontLabel.font = [UIFont fontWithName:@"iconfont" size:50];
//添加Unicode编码,格式为\U0000 + 图标的Unicode编码
iconfontLabel.text = @"\U0000e64e";
//显示label
[self.view addSubview:iconfontLabel];
-
添加图标成功image




