UITextField的屬性設定

2022-07-22 19:30:16 字數 1212 閱讀 7178

1.背景顏色 field.backgoundcolor = [uicolor redcolor];

2.設定field文字 field.text = @"輸入文字";

3.設定field的提示文字 field.placeholder = @"請輸入使用者名稱";

4.設定field開始編輯時清除提示內容 field.clearsonbeginediting = yes;  

5.設定field的文字大小 field.font = [uifont systemfontofsize:14];

6.設定文字顏色 field.textcolor = [uicolor redcolor];

7.設定文字對齊方式 field.textalignment = nstextalignmentcenter;

8.輸入密碼安全輸入 field.securetextentry = yes;

9.彈出鍵盤樣式  field.keyboardtype = uikeyboardtypealphabet;

11.設定輸入框的外觀 field.borderstyle = uitextborderstyleline;

12.輸入框後面的清除按鈕:field.clearbuttonmode = uitextfieldviewmodeunlessediting;

13.彈出的鍵盤最後的return可改為其它的,next,search等  field.returnkeytype = uireturnkeynext;

14.自定義彈出檢視: field.inputview

uiview *view = [[uiview alloc] initwithframe:cgrectmake(0, 0, [uiscreen mainscreen].bounds.size.width, 200)];

view.backgroundcolor = [uicolor graycolor];

field.inputview = view;

[view release];

15.彈出乙個輔助檢視:field.inputaccessoryview

uiview *supview = [[uiview alloc] initwithframe:cgrectmake(0, 0, 0,30)];

supview.backgroundcolor = [uicolor darkgraycolor];

field.inputaccessoryview = supview;

UITextField屬性詳解

uitextfield是我們經常用的之一但是常用的屬性都很熟悉,有些不常用的我也總結下,例如下面的 uiimageview myview uiimageview alloc initwithimage uiimage imagenamed face.png uiimageview myview2 u...

UITextField 屬性講解

uitextfield是我們經常用的之一但是常用的屬性都很熟悉,有些不常用的我也總結下,例如下面的 uiimageview myview uiimageview alloc initwithimage uiimage imagenamed face.png uiimageview myview2 u...

UITextField 屬性詳細解釋

uitextfield是我們經常用的之一但是常用的屬性都很熟悉,有些不常用的我也總結下,例如下面的 uiimageview myview uiimageview alloc initwithimage uiimage imagenamed face.png uiimageview myview2 u...