Uilabel,uitextfield and UIButton applications

Source: Internet
Author: User
Tags uicontrol

</pre><pre name= "code" class= "CPP" > I. UILabel it is the control used by iOS development to display text, it is UIView subclass, so the detail UIView function, Just more than uiview the function of the text display, the use of the process is also divided into four steps: 1. Create object 2. Add to Parent View 4. Release the full weight focus: Different controls are just the difference between the configured properties, which is where the differences are, so learning A new control that only has properties that are unique to the control can be 1. Create an object UILabel *view = [[UILabel alloc] Initwithframe:cgrectmake (60, 234, 200, 100)];2. Set LA The text displayed on Bel View.text = @ "Beauy:beauybeauybeauy"; 3. Sets the size of the text on the label//1. Set font style//2. Set the font size//systemfontofsize default using system default       Font, ability to change size View.font = [Uifont systemfontofsize:25];    View.font = [Uifont fontwithname:@ "Thonburi-bold" size:25];    [Uifont Familynames] Gets the name of the font family//NSLog (@ "%@", [Uifont familynames]); NSLog (@ "%@", [Uifont fontnamesforfamilyname:@ "Thonburi"]); 4. Font Color View.textcolor = [Uicolor yellowcolor];5. Sets the alignment style for text view.textalignment = nstextalignmentcenter;6. Set text wrapping//Assuming that the number of rows is not limited, set the value to 0 view.numberoflines = 0;7. Standard for line breaks (text Interception principle) View.linebreakmode = nslinebreakbywordwrapping;8. Sets the offset of the shadow View.shadowoffset = CgsiZemake (0, 0); 9. Shadow color View.shadowcolor = [Uicolor Redcolor]; Two. Uitextfield is a subclass of Uicontrol, Uicontrol is also a subclass of UIView, so it's a view, just two more features than UIView: text display and text editing//Uitextfield    Use the same steps as the UIView 1. Create object: Uitextfield *textfield = [[Uitextfield alloc] Initwithframe:cgrectmake (40, 50, 240, 30)]; Textfield.backgroundcolor = [Uicolor yellowcolor];2. Set border Style Textfield.borderstyle =uitextborderstyleroundedrect;3. Set the default display (hint text) text, but not as part of the text content Textfield.placeholder = @ "mobile phone number/mailbox"; 4. Set start display text Textfield.text = @ "phone number"; 5. Set the text color Textfie Ld.textcolor = [Uicolor redcolor];6. Set text Alignment textfield.textalignment = nstextalignmentcenter;7. Set font for text//TEXTFIELD.F ont = [uifont fontwithname:@ "Thonburi" size:35];8. Sets whether the input box can be edited textfield.enabled = yes;9. Sets whether to clear the input box content when editing is started TEXTFIELD.C learsonbeginediting = yes;10. Sets the password mode in which the contents of the input box are displayed as dots textfield.securetextentry = yes;11. Set the style of the pop-up keyboard textfield.ke Yboardtype = uikeyboardtypeasciicapable;12. The lower-right corner of the keyboard shows the style Textfield.returnkeytype = uireturnkeydefault;13. Agent//Agent Usage steps: 1. Set up proxy 2. Obey the agreement 3. Implement the method in the Protocol textfield.delegate = self;14. Define the input view yourself (default keyboard) UIView *view = [[UIView alloc] Initwit    Hframe:cgrectmake (20, 50, 20, 50)];    Textfield.inputview = view;    [_containview Addsubview:textfield]; [TextField release];} When you click Return in the lower right corner will trigger-(BOOL) Textfieldshouldreturn: (Uitextfield *) textfield{//Recycle keyboard, cancel first responder [TextField RESIGNFIRSTRESP    Onder]; return YES;}    Three. UIButton UIButton *button =[uibutton Buttonwithtype:uibuttontypesystem];    Button.frame = CGRectMake (50, 400, 220, 40); Button.backgroundcolor = [Uicolor browncolor];1. Set Fillet Button.layer.cornerRadius = 5;2. Add a Click event to the button//Let Target run the action Method, after the ControlEvents event occurs//click: The following: Who calls Addtarger:action: method, the number of participants is who, and the number of parameters can only have a [button addtarget:self action: @sel Ector (click:) forcontrolevents:uicontroleventtouchupinside];3. Set Text To button [button settitle:@ "Confirm" forstate:    uicontrolstatenormal];4. Changing the color of text [button Settitlecolor:[uicolor Redcolor] forstate:uicontrolstatenormal]; [_CONTAINVIew Addsubview:button];    }-(void) Click: (UIButton *) button{NSLog (@ "%@", button); NSLog (@ "Reggiezon affixed");}


Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

Uilabel,uitextfield and UIButton applications

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.