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