Uilable Related foundation of Ios:ui design

Source: Internet
Author: User

  Uilable is the most basic control of the iphone interface and is used primarily to display textual information.

  Basic methods of Use:

UILabel *label = [[UILabel alloc]initwithframe:cgrectmake (x,y,w,h)]; //Initialize

Label.center = Self.window.center; //Set label to center relative to window

Label.text = @ "UILabel"; //Set text content

NSLog (@ "%@", Label.text); //Read content 

label.highlighted = YES; //Whether highlight

Label.highlightedtextcolor = [Uicolor Yellowcolor]; //color of the font when highlighted

Label.background = [Uicolor Redcolor]; //Set the label's background color

Label.font = [Uifont systemfontofsize:14]; //Set text font size (default font Size: 17), general method

Label.font = [Uifont boldsystemfontofsize:14]; //Bold method

Label.font = [Uifont fontwithname:@ "Arial" size:14]; //How to specify Fonts

Label.textcolor = [Uicolor Bulecolor]; //Text color

Label.shadowcolor = [Uicolor Graycolor]; //Set shadow color

Label.shadowoffset = Cgsizemake ( -4,-4); //Set the amount of partial yin

      // when the text is longer than frame range, text interception method:

Label.linebreakmode = Nslinebreakbytruncatingtail; The contents of the//end section are omitted in the "text ..." mode, displaying the text content of the header.

              Nslinebreakbytruncatinghead; ///Front part of the text with "... Text " way omitted, display trailing text content.

              Nslinebreakbytruncatingmiddle; //middle content with "text ... the text "way omitted, displays the text content of the tail and kinsoku.

nslinebreakbywordwrapping; //Displays the word as the display unit, and the trailing part is omitted.

              nslinebreakbyclipping; //Simple tailoring, up to the border

              nslinebreakbycharwrapping; //Preserve entire characters

      To set the alignment of a font

Label.textalignment = Nstextalignemtcenter; //Center alignment

             Nstextalignmentleft; //Align Left

             Nstextalignmentright; //Right Justify

Label.    adjustsfontsizetofitwidth = YES; //Set font size to fit label width

Label.     NumberOfLines = 0; //Set number of rows, when =0, indicates no limit on number of rows, for multiple lines

[Label SizeToFit]; //label according to the content, with the above numberoflines,adjustsfontsizetofitwidth settings conflict, can only use one of the

label.baselineadjustment = Uibaselineadjustmentnone; //The lowest end of the text is aligned with the label centerline. (If the adjustsfontsizetofitwidth property is set set to Yes, this property controls the behavior of the text baseline. )

                uibaselineadjustmentaligncenters; the middle of the text is aligned with the label centerline.

                Uibaselineadjustmentalignbaselines = 0; //default, the top of the text is aligned with the centerline.

label.enable = no; //enabled just determines how the label is drawn, setting it to no will darken the text, indicating that it is not active, and setting a color value to it is not valid.

Label.adjustsletterspacingtofitwidth = NO; //Whether to change the spacing between letters to fit the label size

     Vertical text displays each text plus a newline character, which is the most convenient and easy way to implement:

Label.text = @ "please \ \ \ \ \ \ \ \ \ \ \ \ \ \"

Label.numberoflines = [Label.text length];

     Set the label's border color, thickness

Label.layer.borderColor = [[Uicolor graycolor] cgcolor];

Label.layer.borderWidth = 5;

(May learn relatively shallow, if you have to add can leave a message, there are questions to discuss with you, you can contact privately: Qq790444804:hgwchihuo

-------I'm a happy little tail ' (*∩_∩*)

Uilable Related foundation of Ios:ui design

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.