- (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的屬性介紹
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.