@implementationviewcontroller
- (void
)viewdidload uitextborderstyle;
textfield1.borderstyle =uitextborderstyleroundedrect;
textfield1.text = @"
hello,textfield";
textfield1.placeholder = @"
please input the text";
//設定字型及大小
textfield1.font = [uifont fontwithname:@"
arial
" size:10.0f
];
//設定字型顏色
textfield1.textcolor =[uicolor bluecolor];
//typedef enum uitextfieldviewmode;
textfield1.clearbuttonmode =uitextfieldviewmodealways;
//採用星號加密顯示
textfield1.securetextentry =no;
//定義彈出的軟鍵盤型別
//uikeyboardtypedefault 預設全部
//uikeyboardtypenumberpad 數字鍵盤
//型別較多,此處省略
textfield1.keyboardtype =uikeyboardtypedefault;
//定義軟鍵盤上的回車按鍵的樣式
//uireturnkeydefault, 預設 灰色按鈕,標有return
//uireturnkeygo, 標有go的藍色按鈕
//型別較多此處省略
textfield1.returnkeytype =uireturnkeydefault;
//左側或右側增加
uiimageview *image=[[uiimageview alloc] initwithimage:[uiimage imagenamed:@"
person.png
"]];
textfield1.leftview=image;
textfield1.leftviewmode =uitextfieldviewmodealways;
[self.view addsubview:textfield1];
}#pragma mark - textfield delegates
//開始編輯時出發**
-(void)textfielddidbeginediting:(uitextfield *)textfield
//結束編輯時出發**(軟鍵盤消失)
-(void)textfielddidendediting:(uitextfield *)textfield
//回車時被**
-(bool) textfieldshouldreturn:(uitextfield *)textfield
@end
UI控制項 UITextfield詳解
介紹一些常用的屬性 clearbuttonmode 這個顯示的是右邊的小 按鈕,列舉,never,whileediting,unlessediting,always returnkeytype 這個是彈出鍵盤右下角位置的按鈕,列舉,default,go,google,join,next,route,...
UI基礎之UITextField相關
uitextfield textf uitextfield alloc init 1 字型相關 textf.text 文字框文字 textf.textcolor uicolor bluecolor 字型顏色 textf.textalignment nstextalignmentcenter 文字對齊...
IOS控制項之UITextField用法及注意點
主要總結工作中常用到的ui控制項的屬性,同時使用應注意的地方以及工作中常犯錯誤,進行了總結.若有不屬性的,可自己自己做demo看一下效果 初始化方法 uitextfield tf uitextfield alloc initwithframe cgrectmake x,x,x,x 設定邊框樣式 tf...