Uitextfield common attributes and keyboard for uitextfield Revocation

Source: Internet
Author: User

Uitextfield is a subclass of uicontrol, and uicontrol is a subclass of uiview, so it is also a view, but there are two more functions than uiview, 1. text display, 2. text editing

The procedure is as follows:

1. Create an object

2. Configure attributes

3 add to parent View

4. Release ownership

1. Create an object

Uitextfield * text = [[uitextfieldalloc] initwithframe: cgrectmake (,)]; text. backgroundcolor = [uicoloryellowcolor]; [_ viewaddsubview: text]; [textrelease];

2. Set the border style (rounded corner) of Text)

Text. borderstyle = uitextborderstyleroundedrect;

3. Set text to display text by default (but not as part of text content)

Text. placeholder = @ "Enter the user name ";

4. Set text

Text. Text = @ "What is broken ";


5. set text color

Text. textcolor = [uicolorblackcolor];

6. set text alignment

Text. textalignment = nstextalignmentcenter;

7. set text font

Text. font = [uifont systemfontofsize: 18];

8. Set whether the input box can be edited.

Text. Enabled = yes;

9. Set whether to clear the content in the box when editing starts.

Text. clearsonbeginediting = yes;

10. Set the password format (whether the content in the input box is displayed as a dot)

Text. securetextentry = yes;

11. Set the pop-up keyboard style (numeric keyboard)

Text. keyboardtype = uikeyboardtypenumberpad;

12. display style in the lower right corner of the keyboard

Text. returnkeytype = uireturnkeygo;


13. Set the tag Value
Text. Tag = 120;


14. keyboard recycling


1. Click the lower right corner or press enter to recycle the keyboard.
1. Set proxy
Text. Delegate = self;

2. Obey the agreement
Add the protocol to the corresponding. h file, as shown in figure
@ Interface mayappdelegate: uiresponder <uiapplicationdelegate, uitextfielddelegate>
Obey, <uitextfielddelegate> Protocol

3. Methods in the Implementation Protocol
-(Bool) textfieldshouldreturn :( uitextfield *) textfield

{

Reclaim the keyboard and cancel the first responder

[Textfield resignfirstresponder]; returnyes;

}

2. Click the blank space to clear the keyboard
1. Set proxy
Text. Delegate = self;

2. Obey the agreement
Add the protocol to the corresponding. h file, as shown in figure
@ Interface mayappdelegate: uiresponder <uiapplicationdelegate, uitextfielddelegate>
Obey, <uitextfielddelegate> Protocol

3. Methods in the Implementation Protocol

-(Void) touchesended :( nsset *) touches withevent :( uievent *) event {

[Text resignfirstresponder];

}

Uitextfield common attributes and keyboard for uitextfield Revocation

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.