標籤:
UITextField* textField=[[UITextField alloc]initWithFrame:CGRectMake(60, 100, 200, 30)]; //屬性 //樣式 textField.borderStyle=UITextBorderStyleBezel;//矩形有陰影 textField.borderStyle=UITextBorderStyleLine;//矩形沒有陰影 textField.borderStyle=UITextBorderStyleNone;//無邊框 textField.borderStyle=UITextBorderStyleRoundedRect;//邊角為圓形 textField.text=@"sdf";//預設字型 textField.placeholder=@"在此輸入。。。";//提示輸入 textField.textAlignment=NSTextAlignmentCenter;//置中 textField.secureTextEntry=YES;//安全輸入,密碼框 textField.clearButtonMode=UITextFieldViewModeWhileEditing;//設定文字框右邊有個清除欄 textField.keyboardType = UIKeyboardTypePhonePad; // 彈出的鍵盤的樣式,彈出數組鍵盤 textField.keyboardAppearance=UIKeyboardAppearanceAlert;//設定鍵盤的顏色為深灰,預設是淺灰色UIKeyboardAppearanceDefault textField.clearsOnBeginEditing = YES; // 再次編輯就清空原有的內容 textField.minimumFontSize = 20.0f; // 設定自動縮小顯示的最小字型大小 textField.secureTextEntry = NO; // 設定是否以密碼的圓點形式顯示 textField.autocorrectionType = YES; // 設定是否啟動自動提醒更新功能 textField.returnKeyType = UIReturnKeyDefault; // 設定彈出的鍵盤帶形式與帶的按鍵 [self.view addSubview:textField];
//當開始點擊textField會調用的方法-(void)textFieldDidBeginEditing:(UITextField *)textField { NSLog(@"開始編輯"); }//當textField編輯結束時調用的方法-(void)textFieldDidEndEditing:(UITextField *)textField { NSLog(@"結束編輯"); }//按下Done按鈕的調用方法,我們讓鍵盤消失-(BOOL)textFieldShouldReturn:(UITextField *)textField{ [textField resignFirstResponder]; return YES; }- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}
IOS 學習筆記---UITextField的一些屬性