- (void)viewDidLoad
{
[super viewDidLoad];
/*
Accessing the Text Attributes
text property
font property
textColor property
textAlignment property
lineBreakMode property
enabled property
Sizing the Label’s Text
adjustsFontSizeToFitWidth property
baselineAdjustment property
minimumFontSize property 无例
numberOfLines property
Managing Highlight Values
highlightedTextColor property
highlighted property
Drawing a Shadow
shadowColor property
shadowOffset property
userInteractionEnabled property
*/
UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 20.0, 200.0, 50.0)];
UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 80.0, 200.0, 50.0)];
UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 140.0, 200.0, 50.0)];
UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 200.0, 200.0, 50.0)];
//设置显示文字
label1.text = @"label111111111111111";
label2.text = @"label2";
label3.text = @"label3--label3--label3--label3--label3--label3--label3--label3--label3--label3--label3--";
label4.text = @"label4--label4--label4--label4--";
//设置字体大小
label1.font = [UIFont systemFontOfSize:20.0];
label2.font = [UIFont boldSystemFontOfSize:20.0];//粗体
//文字颜色
label1.textColor = [UIColor redColor];
//文字对齐方式
//label1.textAlignment = UITextAlignmentCenter; //iOS6.0中已弃用
//linebreakmode 文字打断模式(过长) 默认位NSLineBreakByWordWrapping
label2.lineBreakMode = NSLineBreakByClipping;
//enabled 是否可用(是否响应事件和文字是否修改)
label2.enabled = YES;
//Sizing the Lable's text
label2.adjustsFontSizeToFitWidth = YES;
// label1.baselineAdjustment = UIBaselineAdjustmentAlignCenters;
//miniumFontSize //iOS6.0中已弃用
//label1.minimumFontSize = 14;
//设置lable的行数
label4.numberOfLines = 3;
//Managing Highlight values
//设置高亮
label1.highlighted = YES;
label1.highlightedTextColor = [UIColor orangeColor];
//设置阴影
label3.shadowColor = [UIColor redColor];
label3.shadowOffset = CGSizeMake(2.0, 2.0);
//设置交互
label3.userInteractionEnabled = YES;
[self.view addSubview:label1];
[self.view addSubview:label2];
[self.view addSubview:label3];
UILable的属性介绍
最新推荐文章于 2017-03-22 15:57:29 发布