【ios开发学习 - 第六课】UILabel使用

  UILabel *label = [[UILabel allocinitWithFrame:CGRectMake(007540)];   //初始化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.0f2.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;

你可能感兴趣的:(【ios开发学习 - 第六课】UILabel使用)