//--------------UILable-------------ide
//建立一個標籤字體
UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(80, 40, 200,50)];加密
//給標籤設置內容spa
lable.text = @"Hello World";3d
//給標籤內容設置顏色orm
lable.textColor = [UIColor blackColor];事件
//給標籤設置字體圖片
lable.font = [UIFont fontWithName:@"Arial" size:20];rem
//給標籤設置背景顏色get
//lable.backgroundColor = [UIColor greenColor];
lable.backgroundColor = [UIColor colorWithRed:0.5 green:0.8 blue:0.5 alpha:0.5];
//給標籤設置邊框寬度
lable.layer.borderWidth = 10;
//給標籤設置邊框顏色
//lable.layer.borderColor = [UIColor orangeColor].CGColor;
lable.layer.borderColor = [UIColor colorWithWhite:0.1 alpha:0.3].CGColor;
//字體居中
lable.textAlignment = NSTextAlignmentCenter;
//設置字體:粗體,正常的是SystemFontOfSize
lable.layer.cornerRadius = 20;
//設置陰影
lable.layer.shadowColor=[UIColor blackColor].CGColor;
lable.layer.shadowOffset=CGSizeMake(10, 20);//陰影大小
lable.layer.shadowRadius=20;
//設置lable 的行數
lable.numberOfLines = 2;
//設置lable中文字是否可變,默認爲YES;
lable.enabled = NO;
//設置高亮
lable.highlighted = YES;
lable.highlightedTextColor = [UIColor orangeColor];
//把標籤添加到視圖
[self.view addSubview:lable];
//--------------UITextFiled-------------
//設置一個文本框
UITextField *textFiled = [[UITextField alloc]initWithFrame:CGRectMake(80,100, 200, 50)];
//設置輸入框邊框樣式
textFiled.borderStyle=UITextBorderStyleLine;
//設置輸入框的加密顯示
textFiled.secureTextEntry=YES;
//設置輸入框的字體居中位置
textFiled.textAlignment=NSTextAlignmentCenter;
//當輸入框沒有內容時,水印提示placeholder 提示內容爲password
textFiled.placeholder=@"提示";
//給文本框添加背景顏色
textFiled.backgroundColor = [UIColor colorWithRed:0.6 green:0 blue:0 alpha:0.2];
//將文本框添加到視圖中
[self.view addSubview:textFiled];
//--------------UIButton-------------
//設置一個button
UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(80, 200, 50, 50)];
//設置button內容
[button setTitle:@"click" forState:UIControlStateNormal];
//設置內容顏色
[button setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
//設置button背景顏色
button.backgroundColor = [UIColor colorWithRed:0.5 green:0.5 blue:0 alpha:0.4];
//設置按鈕背景圖片
// [button setBackgroundImage:[UIImage imageNamed:@"0"] forState:UIControlStateNormal];
//設置按鈕邊框
[button.layer setCornerRadius:10.0]; //設置矩形四個圓角半徑
[button.layer setBorderWidth:1.0]; //邊框寬度
[button.layer setBorderColor:[UIColor blueColor].CGColor];//邊框顏色
//給button添加點擊事件
[button addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
//給button移除點擊事件
// [button removeTarget:self action:@selector(<#selector#>) forControlEvents:<#(UIControlEvents)#>]
//將button添加到視圖中
[self.view addSubview:button];