Use of Urtext

Source: Internet
Author: User
Tags uicontrol

    • Uitextfield is Uicontrol subclass, Uicontrol is also UIView subclass, so is a view, but more than UIView two functions, 1. Text display, 2. Editing

      The use of the process is in four steps:

      1. Create an Object

      2. Configuration Properties

      3 Add to Parent view

      4. Release of ownership

      1. Create an Object

      Uitextfield *text = [[Uitextfield alloc] Initwithframe:cgrectmake (50, 50, 180, 50)]; Text.backgroundcolor = [Uicolor Yellowcolor]; [_view Addsubview:text]; [Text release];

      2. Set the text border style (fillet)

      Text.borderstyle = Uitextborderstyleroundedrect;

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

      Text.placeholder = @ "Please enter user name";

      4. Set text text

      Text.text = @ "What tattered";

      5. Set the text color

      Text.textcolor = [Uicolor blackcolor];

      6. Set the alignment of text

      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 contents of the box when you start editing

      text.clearsonbeginediting = YES;

      10. Set the password format (the contents of the input box are displayed as dots)

      Text.securetextentry = YES;

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

      Text.keyboardtype = Uikeyboardtypenumberpad;

      12. Lower right corner of keyboard display style

      Text.returnkeytype = Uireturnkeygo;


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

      14. Keyboard Recycling


      1. Click on the lower right corner or enter to recycle the keyboard
      1. Setting up the agent
      Text.delegate = self;

      2. Compliance with the agreement
      Add the protocol in the corresponding. h file, such as
      @interface Mayappdelegate:uiresponder <UIApplicationDelegate,UITextFieldDelegate>
      Obey the,<uitextfielddelegate> agreement

      3. Implementing the methods in the Protocol
      -(BOOL) Textfieldshouldreturn: (Uitextfield *) TextField

      {

      Recycle keyboard, cancel first responder

      [TextField Resignfirstresponder]; return YES;

      }

      2. Click the empty space to recycle the keyboard
      1. Setting up the agent
      Text.delegate = self;

      2. Compliance with the agreement
      Add the protocol in the corresponding. h file, as
      @interface Mayappdelegate:uiresponder <UIApplicationDelegate,UITextFieldDelegate>
      Obey the,<uitextfielddelegate> agreement

      3. Implementing the methods in the Protocol

      -(void) touchesended: (Nsset *) touches withevent: (Uievent *) Event {

      [Text Resignfirstresponder];

      }

Use of Urtext

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.