Simple use of Uitextfield

Source: Internet
Author: User
Tags transparent color


Simple, practical and explanatory notes on Uitextfield

1- (void) Viewdidload {2 [Super Viewdidload];3 4 //Self.view.backgroundColor = [Uicolor graycolor];5 6 //the input box defaults to full transparency7 //no matter how big the frame is, the default input box height is8Uitextfield *textfield1 = [[Uitextfield alloc] Initwithframe:cgrectmake ( -, -, $, -)];9 //set Border type, default to No borderTenTextfield1.borderstyle =Uitextborderstyleline; One //Set background color, default to Transparent color ATextfield1.backgroundcolor =[Uicolor Orangecolor]; - - [Self.view addsubview:textfield1]; the - - //Set Center -Textfield1.textalignment =Nstextalignmentcenter; + //Set the password display form - //textfield1.securetextentry = YES; + A //Set Keyboard type atTextfield1.keyboardtype =uikeyboardtypeemailaddress; - - //set Clear button to display properly -Textfield1.clearbuttonmode =uitextfieldviewmodewhileediting; - - //Close first letter capitalization inTextfield1.autocapitalizationtype =Uitextautocapitalizationtypenone; - //prompt text When the input box is empty toTextfield1.placeholder =@"Please enter your account number."; + -Textfield1.text =@"Hahha"; the //Set Text font *Textfield1.font = [Uifont systemfontofsize: One]; $ //Set up proxyPanax NotoginsengTextfield1.Delegate=Self ; - //self.ibTextField.delegate = self; the +Textfield1.tag = -; A //Self.ibTextField.tag = $; the /* + To use the Proxy method: - 1. Compliance with agreements $ 2. Setting up the agent $ 3. Implementing the Protocol approach - - */ the - Wuyi } the - #defineMark Textfeilddelegate Wu //Start editing --(BOOL) textfieldshouldbeginediting: (Uitextfield *) textfield{ About $NSLog (@"J will begin editing,%ld", Textfield.tag); - //decide if your TextField can be edited - returnYES; - } A- (void) Textfielddidbeginediting: (Uitextfield *) textfield{ +NSLog (@"Start editing"); the - } $-(BOOL) textfieldshouldendediting: (Uitextfield *) textfield{ the theNSLog (@"going to end the edit"); the returnYES; the - } in the- (void) Textfielddidendediting: (Uitextfield *) textfield{ the AboutNSLog (@"End Edit"); the } the //call when you click the Clear button the-(BOOL) Textfieldshouldclear: (Uitextfield *) textfield{ +NSLog (@"Clear"); - returnYES; the }Bayi //called when the keyboard return is clicked the-(BOOL) Textfieldshouldreturn: (Uitextfield *) textfield{ theNSLog (@"return"); - //Cancel First Responder, close keyboard - [TextField Resignfirstresponder]; the returnYES; the}

Simple use of Uitextfield

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.