ios中UILabel的使用

UILabel定义

UILabel *label=[[UILabel alloc] initWithFrame:CGRectMake(100, 100, 100, 50)];

UILabel的属性

  • 背景色:label.backgroundColor=[UIColor redColor];
  • label文字内容:label.text=@”标签文字”;
  • label中文字对齐方式:label.textAlignment=NSTextAlignmentCenter;
  • 文字的颜色:label.textColor=[UIColor blackColor];
  • 文字的大小:label.font=[UIFont systemFontOfSize:50];
  • label阴影:label.shadowColor=[UIColor greenColor];label.shadowOffset=CGSizeMake(2, 2);
  • 设置行数:label.numberOfLines=2;
  • 圆角:label.layer.cornerRadius=5;label.layer.masksToBounds=YES;

你可能感兴趣的:(ios)