zoukankan      html  css  js  c++  java
  • UIlable

    Label用法总结
    (1)初始化
    UILabel *aLabel=[[UILabel alloc]initWithFrame:CGRectMake(50, 50, 100, 50)];
    (2)文字内容
    //位置默认是靠左的
    [aLabel setText:@"hello"];

    //设置字体颜色
    aLabel.textColor=[UIColor blueColor];
    aLabel.textColor=[UIColor redColor];

    //设置字体大小
    aLabel.font=[UIFont systemFontOfSize:12.4];
    //修改字体的字体和大小
    aLabel.font=[UIFont fontWithName:@"Arial Rounded MT Bold" size:36.0];

    //设置背景颜色
    aLabel.backgroundColor=[UIColor redColor];
    //清空背景颜色
    aLabel.backgroundColor=[UIColor clearColor];

    //设置对齐方式
    aLabel.textAlignment = UITextAlignmentLeft;//文字靠左
    aLabel.textAlignment = UITextAlignmentCenter;//文字居中
    aLabel.textAlignment = UITextAlignmentRight;//文字靠右

    //设置字体大小是否适应label宽度
    aLabel.adjustsFontSizeToFitWidth=YES;//是YES时,这个属性就来控制文本基线的行为
    在定义里面允许有以下格式显示:  
      typedef enum {    
     
          UIBaselineAdjustmentAlignBaselines,   //默认值文本最上端与label中间线对齐
     
          UIBaselineAdjustmentAlignCenters,   //text中间与label中间线对齐
     
         UIBaselineAdjustmentNone,    //text最低端与label中间线对齐
     
     } UIBaselineAdjustment;    



    //设置是否是高亮
    aLabel.highlighted=YES;
    //高亮颜色
    aLabel.highlightedTextColor=[UIColor redColor];


    //设置阴影颜色
    aLabel.shadowColor=[UIColor blueColor];
    //阴影偏移量
    aLabel.shadowOffset=CGSizeMake(0.5, 0.5);

    //是否能和用户交互
    aLabel.userInteractionEnabled=YES;
    //文字是否可变,默认值是YES
    aLabel.enabled=YES;


    //设置文字过长时的显示格式
    aLabel.lineBreakMode = UILineBreakModeMiddleTruncation;//截去中间
    aLabel.lineBreakMode =UILineBreakModeTailTruncation,//截去尾部
    aLabel.lineBreakMode =UILineBreakModeHeadTruncation;//截去头部
    aLabel.lineBreakMode=UILineBreakModeCharacterWrap;//保留整个字符
    aLabel.lineBreakMode=UILineBreakModeClip;//截去多余部分

    在定义里面允许有以下格式显示:  
    typedef enum {

     UILineBreakModeWordWrap = 0, //

     UILineBreakModeCharacterWrap,

      UILineBreakModeClip,//截去多余部分

      UILineBreakModeHeadTruncation,//截去头部

      UILineBreakModeTailTruncation,//截去尾部

      UILineBreakModeMiddleTruncation,//截去中间

    } UILineBreakMode;

  • 相关阅读:
    Mybatis整理
    Spring获取json和表单
    Mqtt(paho)重连机制
    Redis无法获取资源(Could not get a resource from the pool)
    SSM+Maven+Redis框架学习
    第一章 Zookeeper理论基础
    RocketMQ和Kafka对比
    Kafka工作原理与过程
    Kafka介绍
    JVM调优
  • 原文地址:https://www.cnblogs.com/guoxiaobing/p/4951060.html
Copyright © 2011-2022 走看看