/Initialize input box and set position and size Uitextfield *textfield = [[Uitextfield alloc] Initwithframe:cgrectmake (10, 100, 300, 30)];// Set the input box prompt Textfield.placeholder = @ "TextField tip";//input box with pre-entered text Textfield.text = @ "Pre-entered text";//Set Input box textFont textfield.font = [Uifont fontwithname:@ "Arial" size:20.0f];//set input box font color Textfield.textcolor = [Uicolorredcolor];//Setting the input boxBackground color Textfield.backgroundcolor = [uicolor graycolor];//set Input boxBorder Style Textfield.borderstyle = Uitextborderstyleroundedrect;//There are several border styles://enum {//uitextborderstylenone, no border, default//uitextborderstyleline, Linetype border//uitextborderstylebezel, Linetype border and shadow/ /uitextborderstyleroundedrect with rounded border//} uitextborderstyle;//Set whether the input box is for password Textfield.securetextentry = no;//Set whether there is a purgebutton, when displayed, to delete all the contents of the input box at once Textfield.clearbuttonmode = uitextfieldviewmodewhileediting;//The purge button style has the following types://enum {// Uitextfieldviewmodenever, never appear//uitextfieldviewmodewhileediting, edit//uitextfieldviewmodeunlessediting appear, In addition to editing appears//uitextfieldviewmodealways always appear//} uitextfieldviewmode;//set automatic error correction mode Textfield.autocorrectiontype = uitextautocorrectiontypeno;//automatic error correction methods are as follows://enum {//uitextautocorrectiontypedefault, default// Uitextautocorrectiontypeno, no automatic error correction//uitextautocorrectiontypeyes, auto Error correction//} uitextautocorrectiontype;// Set the automatic capitalization method Textfield.autocapitalizationtype = uitextautocapitalizationtypenone;//Automatic capitalization is available in the following ways://enum {// Uitextautocapitalizationtypenone, do not automatically capitalize//uitextautocapitalizationtypewords, capitalize the first letter of the word// Uitextautocapitalizationtypesentences, the first letter of the sentence is capitalized//uitextautocapitalizationtypeallcharacters, all letters are capitalized//} uitextautocapitalizationtype;//settings edit again whether to empty textfield.clearsonbeginediting = yes;//Set text alignment textfield.textalignment = nstextalignmentleft;//iOS7 Chinese text alignment in the following ways://enum {//nstextalignmentleft= 0, left-aligned, default//nstextaliGnmentcenter= 1, center-aligned//nstextalignmentright = 2, right-aligned//nstextalignmentjustified = 3, naturally aligned at the last line of a paragraph Nstextalignmentnatural = 4, default alignment//} nstextalignment;//settingsWhether the font size automatically adapts to the input box width, the default is to keep the original size, long text scrolling textfield.adjustsfontsizetofitwidth = yes;// Set the minimum font size for auto-zoom textfield.minimumfontsize = 20;//SettingsKeyboard styles Textfield.keyboardtype = uikeyboardtypenumberpad;//keyboard styles are available in the following ways://enum {//uikeyboardtypedefault, default keyboard, all characters supported// Uikeyboardtypeasciicapable, ASCII-enabled default keyboard//uikeyboardtypenumbersandpunctuation, standard phone keypad, +*# character support//uikeyboardtypeurl , a URL keyboard that supports only URL characters, supports. comButton//uikeyboardtypenumberpad,Numeric keypad//uikeyboardtypephonepad, telephone keypad//uikeyboardtypenamephonepad, support for entering person's phone keypad//uikeyboardtypeemailaddress, e-mail keyboard// Uikeyboardtypedecimalpad, digital keypad with numbers and decimal points//uikeyboardtypetwitter, optimizedKeyboard for easy input @, #字符//uikeyboardtypealphabet = uikeyboardtypeasciicapable,//} uikeyboardtype;// Set Return key Style Textfield.returnkeytype = uireturnkeydone;//Return key has the following styles://enum {//uireturnkeydefault, default, Gray button, Marked with Return//uireturnkeygo, with Go Blue button//uireturnkeygoogle, labeled with Google's blue button, used to search//uireturnkeyjoin, labeled join blue button//uireturnkeynext, Blue button labeled Next//uireturnkeyroute, blue button labeled route//uireturnkeysearch, blue button labeled Search//uireturnkeysend, blue button labeled Send// Uireturnkeyyahoo, blue button labeled Yahoo//uireturnkeyyahoo, blue button labeled Yahoo//uireturnkeyemergencycall, Emergency call button//} Uireturnkeytype; Set keyboard appearance textfield.keyboardappearance = uikeyboardappearancedefault;//keyboard appearance There are two kinds://enum {// Uikeyboardappearancedefault, default appearance, Light gray//uikeyboardappearancealert, dark grey, graphite//} uireturnkeytype;//set Agent, Used to implement protocol textfield.delegate = self; Rightmost add picture is the following code, the left like uiimageview *image = [[Uiimageview alloc] Initwithimage:[uiimage imagenamed:@ " Right.png "]];textfield.rightview = Image;textfield.rightviewmode = uitextfieldviewmodealways;//Add the input box to the view [Self.view addsubview:textfield];//Press RETURN to close keyboard-(BOOL) Textfieldshouldreturn: (Uitextfield *) textfield{[ Text Resignfirstresponder];return YES;}
Two –uilabel usage Summary of iOS development series