iOS IconFont矢量图标使用方法
2019-08-16 本文已影响0人
纵昂
一、IconFont矢量图标使用方法
第一步登陆阿里矢量图网站:https://www.iconfont.cn/
第二步创建项目,选择图标管理点击我的项目

第三步:创建项目,点击,弹出弹出框,输入项目名称即可


第四步:进入首页选择图标,任意选择四个图标,一定要点击加入购物车。
如果是UI做的图标可以让UI上传上来的,很方便调用

第五步,然后进入和购物车选择添加项目(选择刚刚创建好的项目文件名称)


第六步进入到我的项目选择下载本地

第七步好后解压文件

第八步将iconfont.ttf拖入项目,并配置plist文件

第九步,plist文件配置

第十步就可以按如下编码了
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
// 消息  淘宝     
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 50, 300, 40)];
label.font = [UIFont fontWithName:@"iconfont" size:35];
//  转换 \U0000e618
label.text = @"\U0000e618 \U0000e62c \U0000e62f \U0000e62a \U0000e61e";
label.textColor = [UIColor redColor]; //改变字体颜色就是改变图片颜色
[self.view addSubview:label];
}
一、2020年7月4日记录 实现渐变色效果,字体和矢量图同理
UIView * moneryView = [[UIView alloc]initWithFrame:CGRectMake(0, 160, 165, 165)];
// moneryView.backgroundColor = [UIColor redColor];
[self.view addSubview:moneryView];
UILabel * moneyLal = [[UILabel alloc]init];
// moneyLal.font = [UIFont fontWithName:@"DIN-Medium" size:163];
moneyLal.font = [UIFont fontWithName:@"iconfont" size:50];
// moneyLal.text =@"3000";
moneyLal.text = @"\U0000e64a"; //
[moneyLal sizeToFit];
moneyLal.center = CGPointMake(moneryView.frame.size.width/2, moneryView.frame.size.height/2);
[moneryView addSubview:moneyLal];
CAGradientLayer *gl = [CAGradientLayer layer];
gl.frame = CGRectMake(0,0,414,110);
gl.startPoint = CGPointMake(0, 1);
gl.endPoint = CGPointMake(1, 0);
gl.colors = @[(__bridge id)[UIColor colorWithRed:247/255.0 green:72/255.0 blue:104/255.0 alpha:1.0].CGColor, (__bridge id)[UIColor colorWithRed:79/255.0 green:108/255.0 blue:255/255.0 alpha:1.0].CGColor];
gl.locations = @[@(0), @(1.0f)];
[moneryView.layer addSublayer:gl];
gl.mask = moneyLal.layer;
实现效果:

Demo地址:https://github.com/ZongAng123/IconFontiOS
有什么不懂得可以问我加我QQ群:335429229