UITextField

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

self.window.backgroundColor = [UIColor whiteColor];

[self.window makeKeyAndVisible];

self.window.rootViewController = [[UIViewController alloc] init];

[_window release];

//UITextField

UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];

textField.backgroundColor = [UIColor orangeColor];

[self.window addSubview:textField];

[textField release];

/********* 文本控制 *******/

//占位字符串? placehoder

textField.placeholder = @"哈哈哈哈哈哈哼哈";

/******** 輸入控制 ********/

// 是否可用 enabled? 默認為YES

textField.enabled = YES;

//安全文本輸入? secureTextEntry

textField.secureTextEntry = YES;

//鍵盤樣式 keyboardType

//設(shè)置鍵盤樣式,比如銀行取款密碼只需要數(shù)字,有的輸入郵箱需要@等等

//UIKeyboardTypeAlphabet和UIKeyboardTypeDefault類似,就是我們平時看到那樣,都是字母,然后有個按鍵可以切換符號

//UIKeyboardTypeASCIICapable好像和上面差不多

//UIKeyboardTypeDecimalPad,UIKeyboardTypeNumberPad都是數(shù)字,但前者多了一個“小數(shù)點”按鍵

//UIKeyboardTypeEmailAddress-除了字母還有小數(shù)點和@出現(xiàn)

//UIKeyboardTypeNamePhonePad-貌似正常

//UIKeyboardTypePhonePad-電話鍵盤,不僅有數(shù)字還有*和#的那種

//UIKeyboardTypeNumbersAndPunctuation-只有數(shù)字和標點符號

//UIKeyboardTypeTwitter-除了字母還有@和#,這是微博的符號

//UIKeyboardTypeURL-除字母,還有.com按鈕,方便輸入

//UIKeyboardTypeWebSearch-主要區(qū)別在于return鍵變成了GO鍵

textField.keyboardType = UIKeyboardTypeDefault;

//return(回車按鍵)樣式

textField.returnKeyType = UIReturnKeyGoogle;

//開始輸入時清空

textField.text = @"輸入的內(nèi)容";

textField.clearsOnBeginEditing = YES;

// 自定義鍵盤

UIView *textView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];

textView.backgroundColor = [UIColor greenColor];

//給輸入框指定輸入視圖為新建的view

//? ? textField.inputView = textView;

//自定義輸入輔助視圖

textField.inputAccessoryView = textView;

/******** 外觀控制 ********/

//輸入框樣式

textField.borderStyle = UITextBorderStyleNone;

textField.layer.borderWidth = 1;

//邊框顏色

textField.layer.borderColor = [UIColor blueColor].CGColor;

//切圓角(圓形 : 正方形邊長的一半)

textField.layer.cornerRadius = 10;

//清楚按鈕

textField.clearButtonMode = UITextFieldViewModeAlways;

return YES;

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容