標籤:背景顏色 1.4 run nes trunc col 陰影 nbsp imp
//// ViewController.m// 02-UILabel的使用//// UILabel顯示一段文字。#import "ViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; // 1.1 建立UILabel對象 UILabel *label = [[UILabel alloc] init]; // 1.2 設定frame label.frame = CGRectMake(100, 100, 202, 175); // 1.3 設定背景顏色 label.backgroundColor = [UIColor redColor]; // 1.4 設定文字 label.text = @"da shen 11期最牛逼!!!!da shen da shen da shen da shen da shen "; // 1.5 置中 label.textAlignment = NSTextAlignmentCenter; // 1.6 設定字型大小 label.font = [UIFont systemFontOfSize:20.f]; label.font = [UIFont boldSystemFontOfSize:25.f]; label.font = [UIFont italicSystemFontOfSize:20.f]; // 1.7 設定文字的顏色 label.textColor = [UIColor whiteColor]; // 1.8 設定陰影(預設是有值) label.shadowColor = [UIColor blackColor]; label.shadowOffset = CGSizeMake(-2, 1); // 1.9 設定行數(0:自動換行) label.numberOfLines = 0; // 1.10 顯示模式 label.lineBreakMode = NSLineBreakByTruncatingMiddle; /* NSLineBreakByWordWrapping = 0, // 單詞包裹,換行的時候會以一個單詞換行 NSLineBreakByCharWrapping, // 字元包裹換行,換行的時候會以一個字元換行 NSLineBreakByClipping, // 裁剪超出的內容 NSLineBreakByTruncatingHead, // 一行中頭部省略(注意:numberOfLines要為1): "...wxyz" NSLineBreakByTruncatingTail, // 一行中尾部省略: "abcd..." NSLineBreakByTruncatingMiddle // 一行中中間部省略: "ab...yz" */ // 2.0 添加到控制器的view中 [self.view addSubview:label];}@end
ios6--UILabel