iOS Foundation-uilabel

Source: Internet
Author: User

The most common text label, which is plainly a collection of strings, is used to display the text.

The following is a detailed description label the various properties

-(void) viewdidload{    [Super viewdidload];        UILabel *label = [[UILabel alloc] I nit];       /settings display text     Label.text = @ "This is a text control";   //settings display the text font   & nbsp Label.font = [Uifont systemfontofsize:18.0];   //Set text color     Label.textcolor = [Uicolor redcolor];& nbsp  //Set shadow color     Label.shadowcolor = [Uicolor greencolor];   //Set Shadow size     Label.shadowoffset = Cgsizemake (1.0, 1.0);   /*     typedef ns_enum (Nsinteger, nstextalignment)       {         nstextalignmentleft      = 0 ,     //left-justified          #if   iphone           NS textalignmentcenter    = 1,   //center            Nstextalignmentright &nbs P   = 2,   //Right alignment          #else   ipad           nstextalignmentright     = 1,  &nbs P Visually right aligned           nstextalignmentcenter    = 2,   // Visually centered         #endif   Other            Nstextalignmen tjustified = 3,   //and paragraph alignment            nstextalignmentnatural   = 4,  &NB Sp Default status   normal     } ns_enum_available_ios (6_0);     */   //Text display mode   & nbsp Label.textalignment = nstextalignmentcenter;   //Set the line wrap   But the iOS use is now out of date     Label.linebreakmode = uilinebreakmodecharacterwrap;   //You can now use this line break     Label.numberoflines = 0;    //Set text color in highlighted state     Label.highlightedtextcolor = [Uicolor greencolor];   //Set font minimum   But Minimumfontsize has expired      Label.minimumfontsize = 18.0;    Label.minimumscalefactor = 18.0;   //sets whether the size of the control object adjusts automatically with the size of the header content     [Label setautoresizessubviews:true];   //Set user can operate     label.userinteractionenabled = no;   //Set control's status YES is available     label.enabled = yes;   //Line width specified The maximum value to calculate intrinsic content size    /*     Uilabel and Nstextfield are ambiguous for the intrinsic content size of multiline text.      The height of the text depends on the width of the line, which is also an issue to be clarified when solving constraints.      To solve this problem, these two classes have a property called Preferredmaxlayoutwidth,     This property specifies the maximum value of the line width in order to calculate the intrinsic content size.      */    label.preferredmaxlayoutwidth = 19.0;       // Sets whether the text font is to be reduced to fit the label's area     Label.adjustsfontsizetofitwidth = no;       /*      typedef ns_enum (Nsinteger, uibaselineadjustment) {     Uibaselineadjustmentalignbaselines = 0,//default text topmost in label midline      Uibaselineadjustmentaligncenters, &nbsp    //Text line in label centerline alignment      Uibaselineadjustmentnone,             &NB Sp Text lowest end with label centerline Alignment     };     */   //This value sets the baseline position of the text     Label.baselineadjustment = uibaselineadjustmentalignbaselines;       //Add text to the view of the controller     [Self.view addsubview:label];    


iOS Foundation-uilabel

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.