iOS基础类

iOS IconFont矢量图标使用方法

2019-08-16  本文已影响0人  纵昂

一、IconFont矢量图标使用方法
第一步登陆阿里矢量图网站:https://www.iconfont.cn/
第二步创建项目,选择图标管理点击我的项目

进入我的项目.png
第三步:创建项目,点击,弹出弹出框,输入项目名称即可 点击创建项目 新建内容.png
第四步:进入首页选择图标,任意选择四个图标,一定要点击加入购物车。
如果是UI做的图标可以让UI上传上来的,很方便调用
选择需要的图标.png
第五步,然后进入和购物车选择添加项目(选择刚刚创建好的项目文件名称)
屏幕快照 2019-08-16 上午9.54.15.png
屏幕快照 2019-08-16 上午9.54.25.png
第六步进入到我的项目选择下载本地
屏幕快照 2019-08-16 上午9.56.11.png
第七步好后解压文件
屏幕快照 2019-08-16 上午9.57.35.png
第八步将iconfont.ttf拖入项目,并配置plist文件
屏幕快照 2019-08-16 上午9.58.06.png
第九步,plist文件配置
配置plist文件.png
第十步就可以按如下编码了
- (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];
//   &#xe62f 转换 \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

上一篇 下一篇

猜你喜欢

热点阅读