zoukankan      html  css  js  c++  java
  • UIlabel的字体自适应属性

    有时候我们需要UIlabel根据字数多少来减小字体大小,使得UIlabel能够显示全所有的文字。你需要做的就是设置minimumScaleFactor。minimumScaleFactor默认值是0,此时最小字体就是设置的字体大小,和1的效果一样。

    因此 1、0<minimumScaleFactor<1时才能达到效果。(字体10,想要最小字体5,设置0.5即可)

    2、另外要设置adjustsFontSizeToFitWidth=YES.

    3、还有需要UIlabel的行数是1的时候才有用,多行的label是不行的

    demo:

        UILabel *timeLabel=[[UILabel alloc]initWithFrame:CGRectMake(10, 0, 15015)];

                timeLabel.text=@"测试测试测试测试测试测试测试01111";

                timeLabel.font=[UIFont systemFontOfSize:10];

                timeLabel.adjustsFontSizeToFitWidth=YES;

                timeLabel.minimumScaleFactor=0.5;

  • 相关阅读:
    https://leetcode-cn.com/problems/binary-search/solution/er-fen-cha-zhao-by-leetcode/
    Question_add-two-numbers
    leetcode merge-two-sorted-lists
    leetcode 1108
    leetcode 1107
    git
    sql 语句
    cas
    OMP 算法
    OC----预处理器
  • 原文地址:https://www.cnblogs.com/jx66/p/6061641.html
Copyright © 2011-2022 走看看