UILabel : UIView <NSCoding>
1.創建一個UILabel對象
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(30, 30, 280, 60)];
2.backgroundColor
背景顏色
3.text
顯示的文本信息
eg:label.text = @"顯示的文本信息";
4.textColor
文本顏色
eg:label.textColor = [UIColor yellowColor];
5.shadowColor
文本陰影顏色
eg:label.shadowColor = [UIColor blueColor];
6.shadowOffset
文本陰影偏移量
eg:label.shadowOffset = CGSizeMake(3, 3);
7.textAlignment
文本格式處理(對齊方式)
eg:label.textAlignment = NSTextAlignmentCenter;
8.lineBreakMode
當文本過長時, label顯示的斷行方式
eg:label.lineBreakMode = NSLineBreakByTruncatingHead;
9.numberOfLines
控制label顯示的行數
eg:label.numberOfLines = 0;
10.font
字體大小 系統默認字體大小17
eg:label.font = [UIFont systemFontOfSize:20];
UITextField : UIControl <UITextInput, NSCoding>
1.創建一個UITextField對象
UITextField *name = [[UITextFieldalloc]initWithFrame:CGRectMake(30,100, 280, 30)];
2.placeholder
默認的佔位字符串 一旦輸入 自動隱藏
eg:name.placeholder = @"請在這裏輸入";
3.secureTextEntry
輸入轉換爲黑點
eg:name.secureTextEntry = YES;
4.keyboardType
更改鍵盤類型
name.keyboardType = UIKeyboardTypeASCIICapable;
5.borderStyle
外觀控制
name.borderStyle = UITextBorderStyleRoundedRect;
6.clearButtonMode
清除按鈕
name.clearButtonMode = UITextFieldViewModeWhileEditing;
7.backgroundColor
背景顏色
8.回收鍵盤操作
[textField resignFirstResponder];
9.- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField;
//是否允許輸入
10.- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string;
//限制輸入字符
eg: if ([string isEqualToString:@"a"]) {
return NO;
}
NSLog(@"%@",string);
return YES;
11.- (BOOL)textFieldShouldReturn:(UITextField *)textField;
//返回按鈕調用方法