• (转)UILabel的详细使用


     UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 75, 40)];   //初始化UIlbel并设定frame

        label.backgroundColor = [UIColor clearColor];   //设置label的背景色。

        label.font = [UIFont fontWithName:@"Helvetica-Bold" size:13];   //设置label的字体和字体大小。

        label.transform = CGAffineTransformMakeRotation(0.1);     //设置label的旋转角度

        label.text = @"helloworld";   //设置label所显示的文本

        label.textColor = [UIColor whiteColor];    //设置文本的颜色

        label.shadowColor = [UIColor blackColor];    //设置文本的阴影颜色。

        label.shadowOffset = CGSizeMake(2.0f, 2.0f);     //设置阴影大小。

        label.textAlignment = UITextAlignmentCenter;     //设置文本在label中显示的位置,在Xcode4.5中为NSTextAlignmentCenter。

        //换行技巧:如下换行可实现多行显示,但要求label有足够的宽度。

        label.lineBreakMode = UILineBreakModeWordWrap;     //指定换行模式

        label.numberOfLines = 2;    // 指定label的行数

        label.adjustsFontSizeToFitWidth = YES;//文本大小来适应label,

        label.userInteractionEnabled = YES;//设置是否能与用户进行交互

        //设置文字过长时的显示格式

        label.lineBreakMode = UILineBreakModeMiddleTruncation;//截去中间

        //  typedef enum {

        //      UILineBreakModeWordWrap = 0,

        //      UILineBreakModeCharacterWrap,

        //      UILineBreakModeClip,//截去多余部分

        //      UILineBreakModeHeadTruncation,//截去头部

        //      UILineBreakModeTailTruncation,//截去尾部

        //      UILineBreakModeMiddleTruncation,//截去中间

        //  } UILineBreakMode;

    转自:http://blog.sina.com.cn/s/blog_9693f61a010163b8.html

  • 相关阅读:
    好文章记录
    求职经历
    C正确初始化方式
    linux 常用命令
    MYSQL查找从小到大排列第90%个位置的数据
    最好的单例模式
    <%= %>和${}使用差异
    后台和jsp乱码处理
    浏览器下载文件
    文件下载
  • 原文地址:https://www.cnblogs.com/741162830qq/p/4620450.html
Copyright © 2020-2023  润新知