UI 常用方法總結之--- UILabel UITextField (不斷更新中),uilabeluitextfield
UILabel :UIView <NSCoding>
1.建立一個UILabel對象
UILabel *label = [[UILabelalloc]initWithFrame:CGRectMake(30,30, 280,60)];
2.backgroundColor
背景顏色
3.text
顯示的文本資訊
eg:label.text =@"顯示的文本資訊";
4.textColor
文本顏色
eg:label.textColor = [UIColoryellowColor];
5.shadowColor
文本陰影顏色
eg:label.shadowColor = [UIColorblueColor];
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 = [UIFontsystemFontOfSize: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 ([stringisEqualToString:@"a"]) {
returnNO;
}
NSLog(@"%@",string);
returnYES;
11.- (BOOL)textFieldShouldReturn:(UITextField *)textField;
//返回按鈕調用方法
IOS 中UITextField UILabel有什不同?UITextField是繼承UIControl UILabel 是繼承UIView;
UITextField 可以進行編輯輸入,UILabel不可以. UITextField輸入時有代理進行操作響應.
我特別不理解你拿他倆做什麼比較 你想什麼地方用,有個前提是不是你說的才比較明白