iOS Development Series three-Uitextfield how to use the summary

Source: Internet
Author: User

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, borderless. Default//Uitextborderstyleline, Linetype border//Uitextborderstylebezel, Linetype border and shadow//Uitextborderstyle Roundedrect has rounded border//} uitextborderstyle;//Set whether the input box is used for passwordtextfield.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;//Clear button style has the following://enum {//Uitex Tfieldviewmodenever, never appear//uitextfieldviewmodewhileediting, edit appears//UITEXTFIELDVIEWMODEUNLEssediting, except for edits appear//uitextfieldviewmodealways always appear//} uitextfieldviewmode;//set their own proactive error correction mode TEXTFIELD.A Utocorrectiontype = uitextautocorrectiontypeno;//Own active error correction methods have the following://enum {//Uitextautocorrectiontypedefault, default Uitextautocorrectiontypeno, do not own proactive error correction//Uitextautocorrectiontypeyes, self-correcting//} Uitextautocor    rectiontype;//set its own active capitalization method Textfield.autocapitalizationtype = uitextautocapitalizationtypenone;//own Active capitalization method has the following several:// enum {//Uitextautocapitalizationtypenone, do not own the active capital//Uitextautocapitalizationtypewords, single  Capitalize first letter//uitextautocapitalizationtypesentences, first letter of sentence//uitextautocapitalizationtypeallcharacters, All letters are capitalized//} uitextautocapitalizationtype;//set again to edit whether to empty textfield.clearsonbeginediting = yes;//  Set text Alignment textfield.textalignment = nstextalignmentleft;//IOS7 There are several ways to align the Chinese version://enum {//Nstextalignmentleft = 0, Align Left. Default//Nstextalignmentcenter = 1, centered onQI//nstextalignmentright = 2, right-justified//nstextalignmentjustified = 3, natural alignment at the last line of a paragraph//NSTEXTALIGNM Entnatural = 4, default alignment//} nstextalignment;//sets whether the font size is self-adapting to the input box width. The default is to keep the original size. Long text scrolling textfield.adjustsfontsizetofitwidth = yes;//Set yourself to zoom out the minimum font size shown textfield.minimumfontsize = 20;//                Set the keyboard style Textfield.keyboardtype = uikeyboardtypenumberpad;//keyboard style has the following types://enum {//Uikeyboardtypedefault, The default keyboard. Support for all characters//uikeyboardtypeasciicapable, ASCII default keyboard//uikeyboardtypenumbersandpunctuation, standard telephone keypad, support              With +*# characters//uikeyboardtypeurl, only URL characters are supported on the keyboard, support. combutton//Uikeyboardtypenumberpad, Numeric keypad//UIKEYBOARDTYPEPHONEPAD, telephone keypad//Uikeyboardtypenamephonepad, support for entering the phone key for people's names        Disk//uikeyboardtypeemailaddress, e-mail keypad//uikeyboardtypedecimalpad, numeric keypad with digits and decimal point// Uikeyboardtypetwitter, optimized keyboard. Easy input @, #字符//UikeyboArdtypealphabet = uikeyboardtypeasciicapable,//} uikeyboardtype;//set return key style Textfield.returnkeytype = The uireturnkeydone;//return key has the following styles://enum {//Uireturnkeydefault, default, Gray button.        Marked with return//Uireturnkeygo, blue button//uireturnkeygoogle labeled Go, blue button labeled Google, for searching// Uireturnkeyjoin, Blue button//uireturnkeynext labeled join, Blue button//Uireturnkeyro with Next Ute, Blue button//Uireturnkeysearch marked with the route, Blue button//uireturnkeysend marked with search, marked         Blue button//Uireturnkeyyahoo with Send, blue button//uireturnkeyyahoo with Yahoo, blue button//marked with Yahoo! Uireturnkeyemergencycall, emergency call button//} Uireturnkeytype; Set keyboard appearance textfield.keyboardappearance = uikeyboardappearancedefault;//keyboard appearance There are two kinds://enum {//Uikeyboardappearanc   EDefault, default appearance, light grey//Uikeyboardappearancealert. Dark grey, graphite//} uireturnkeytype;//set up the proxy to implement the Protocol Textfield.delegaTe = self; The right side plus picture is the following code, the left side similar to 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 the return key to close the keyboard-(BOOL) Textfieldshouldreturn: (Uitextfield *) textfield{[text Resignfirstresponder]; return YES;}

This article fixed link: http://www.itechzero.com/ios-development-series-three-uitextfield-usage-summary.html. Reprint please indicate the source.

iOS Development Series three-Uitextfield how to use the summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.