zoukankan      html  css  js  c++  java
  • UILabel---.tff格式字体

    1.将下载的.tff文件导入文件并且导入工程 

    如果导入的时候没有导入工程,手动配置

    project->build phases->copyBundleResources里面添加导入的字体

    2.到plist文件中修改配置

    3,在mac中打开字体,显示的标题为字体名字

    4.如何计算字符串的长宽

    1.确定容器的大小

    a.width或者height一方固定

    b.变化的一方变量一定要足够大

    2.确定计算的font,

    3.调用boundingRectWithSize

    NSString *str =@"

    the underlying attributed string drawn by the label, if set, the label ignores the properties above";//要显示的字

    UIFont *font = [UIFont fontWithName:@"Du Bellay"size:20];//设置字体,大小

    NSDictionary *attrDic = @{NSFontAttributeName:font};

    CGSize bigSize = CGSizeMake(300,3000);//一方固定,一方足够大

    CGSize realSize = [str boundingRectWithSize:bigSize option:NSStringDrawingUsesLineFragmentOrigin attributes:attrDic context:nil].size;

    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10,30,realSize.width,realSize.height)];

    label.text = str;

    label.font =[UIFont fontWithName:@"Du Bellay" size:20];

    labe.textColour = [UIColour colorWithRed:222/225.0 green:59/255.0 blue:17/255.0 alpha:1];

    //对齐方式

    label.textAlignment = NSTextAlignmentLeft;

    lable.backgroundColor = [UIColor yellowColor];

    //设置label显示多少行,0表示多行

    label.numberOfLines = 0;

    设置换行方式,按字符换行

    label.lineBreakMode = NSLineBreakByWordWrapping;

    //投影

    label.shadowOffset = CGSizeMake(-1,-1);

    label.shadowColour = [UIColour redColor];

    [self.view addSubview:label];

    }

    附正则表达式网址:http://www.jb51.net/tools/zhengze.html

  • 相关阅读:
    C语言II博客作业01
    vscode使用相关配置
    Ubuntu配置教程
    编译原理复习
    误差与过拟合
    机器学习分类
    SQL语句使用详解
    CRC模2除法
    数据链路层之差错控制(检错编码和纠错编码)->(奇偶校验码、CRC循环冗余码、海明码)
    封装成帧、帧定界、帧同步、透明传输(字符计数法、字符串的首尾填充法、零比特填充的首尾标志法、违规编码法)
  • 原文地址:https://www.cnblogs.com/yangqinglong/p/5154880.html
Copyright © 2011-2022 走看看