IOS-UI-UILable,iosuilabel自動換行
//用於文本展示
UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(10, 30, 200, 300)];
//使用測色器自選顏色
label.backgroundColor = [UIColor colorWithRed:26/255.f green:124/255.0 blue:248/255.0 alpha:1];
label.text = @"我來自中國,這是個美麗的地方";//文本
label.textColor = [UIColor whiteColor];//字型顏色
label.font = [UIFont systemFontOfSize:18];//系統字型大小
//label.font = [UIFont boldSystemFontOfSize:18];//系統字型加黑粗
//自訂字型
// label.font = [UIFont fontWithName:<#(NSString *)#> size:<#(CGFloat)#>];//自訂字型,第一個參數代表字型名,第二個參數代表大小
label.numberOfLines = 0;//換行設定(0代表預設無效)
label.lineBreakMode = NSLineBreakByCharWrapping;//(多種)換行樣式(line Break Mode換行模式)
label.textAlignment = NSTextAlignmentLeft;//對齊(對齊Alignment)
//需要啟用(允許操作)才能設定文本
label.shadowColor = [UIColor blackColor];//文本的陰影顏色(shadow陰影)
label.shadowOffset = CGSizeMake(2, 2);//文本的陰影位移
label.enabled = NO;//是否啟用,預設YES
//設定標籤
label.tag = 1;
//label.transform = CGAffineTransformMakeRotation(0.4);//設定文本傾斜程度(transform 變換)
[self.view addSubview:label];
[self setLabelText];
}
//設定更換新文本
-(void)setLabelText{
//擷取標籤的對應視圖
// UILabel *label = (UILabel *)[self.view viewWithTag:1];
//label.text = @"新文本";
}