Initialize the input box and set the position and size uitextfield *textfield = [[Uitextfield alloc] Initwithframe:cgrectmake (10, 100, 300, 30)];// Set the input box hint Textfield.placeholder = @ "TextField tip";//input box with pre-entered text Textfield.text = @ "Pre-entered text";//Set font for input box text Textfield.font = [Uifont fontwithname:@ "Arial" size:20.0f];//set input box font color Textfield.textcolor = [Uicolor redcolor];// Set the background color of the input box Textfield.backgroundcolor = [Uicolor graycolor];//set the input box border style Textfield.borderstyle = uitextborderstyleroundedrect;//border Style has the following types://enum {//Uitextborderstylenone, no border, default//Uitextborder Styleline, with Linetype border//Uitextborderstylebezel, Linetype border and shadow//Uitextborderstyleroundedrect with rounded border// } uitextborderstyle;//set whether the input box is used for password Textfield.securetextentry = no;//Set whether there is a purge button, when it is displayed, Used to delete all the contents of the input box at once Textfield.clearbuttonmode = uitextfieldviewmodewhileediting;//The purge button style has the following types://enum {//Uitextfie Ldviewmodenever, never appear//uitextfieldviewmodewhileediting, edit appears//uitextfieldviewmodeunlessediting ExceptThe edits appear//uitextfieldviewmodealways always appear//} uitextfieldviewmode;//set automatic error correction mode Textfield.autocorrectiontyp E = uitextautocorrectiontypeno;//Automatic error correction method has the following types://enum {//Uitextautocorrectiontypedefault, default//Uitextau Tocorrectiontypeno, no auto error correction//Uitextautocorrectiontypeyes, auto Error correction//} uitextautocorrectiontype;//set automatic uppercase Party Textfield.autocapitalizationtype = uitextautocapitalizationtypenone;//Automatic capitalization is available in the following ways://enum {//Uitextautocapita Lizationtypenone, does not automatically capitalize//Uitextautocapitalizationtypewords, capitalize the first letter of the word//Uitextautocapitali Zationtypesentences, first letter of sentence//uitextautocapitalizationtypeallcharacters, all letters Uppercase//} Uitextautocapitaliz ationtype;//settings Edit again if empty textfield.clearsonbeginediting = yes;//Set text alignment textfield.textalignment = Nstextalignmentleft ;//iOS7 Chinese text alignment has the following types://enum {//Nstextalignmentleft = 0, left-aligned, default//Nstextalignmentcenter = 1, habitat Medium Alignment//NstextalignmentriGht = 2, right-justified//nstextalignmentjustified = 3, natural alignment at the last line of a paragraph//nstextalignmentnatural = 4, default alignment// nstextalignment;//sets whether 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;//Set the keyboard style Textfield.keyboardtype = uikeyboardtypenumberpad;// There are several keyboard styles://enum {//Uikeyboardtypedefault, default keyboard, support for all characters//uikeyboardtypeasciicapable, ASCII-enabled default keyboard//uikeyboardtypenumbersandpunctuation, standard telephone keypad, +*# characters//Uikeyboardtypeurl support, URL keyboard that supports only URL characters, supports. com buttons//uikeyboardtypenumberpad, numeric keypad//Uikeyboardtypephonepad, Telephone keypad//UIKEYBOARDTYPENAMEPHONEPAD, phone keypad for entering people's names//uikeyboardtypeemailaddress, e-mail Keyboard//Uikeyboardtypedecimalpad, digital keypad with digits and decimal point//Uikeyboardtypetwitter, optimized keypad for easy input @ , #字符//Uikeyboardtypealphabet = Uikeyboardtypeasciicapable,//} uikeyboardtype;//set return key style Textfield.returnkeytype = uireturnkeydone;//Return key has the following styles://enum {// Uireturnkeydefault, default, Gray button, labeled return//Uireturnkeygo, Go blue button//Uireturnkeygoogle, Blue button labeled Google, for search//Uireturnkeyjoin, blue button with join//Uireturnkeynext, blue by next Knob//Uireturnkeyroute, blue button labeled route//Uireturnkeysearch, blue button labeled search//Uireturnkeys End, blue button//Uireturnkeyyahoo labeled Send, blue button//Uireturnkeyyahoo labeled Yahoo, Blue Button//uireturnkeyemergencycall, Emergency call button//} Uireturnkeytype; Set keyboard appearance textfield.keyboardappearance = uikeyboardappearancedefault;//keyboard appearance There are two kinds://enum {//Uikeyboardappearanc EDefault, default appearance, light gray//Uikeyboardappearancealert, dark grey, graphite//} uireturnkeytype;//set proxy for implementing protocol Textfield.delegate = Self The rightmost plus picture is the following code, with 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 the keyboard-(BOOL) Textfieldshouldreturn: (Uitextfield *) textfield{[text Resignfirstresponder]; return YES;}