Common Properties for iOS text

Source: Internet
Author: User

1.text: Sets the label display text. 2.attributedText: Sets the Label property text.
NSString *text = @ "First";  nsmutableattributedstring *textlabelstr = [[Nsmutableattributedstring alloc] initwithstring:text];  [Textlabelstr setattributes:@{                               nsforegroundcolorattributename: [Uicolor Lightgraycolor],                                  Nsfontattributename: [Uifont systemfontofsize:17]                             } range:nsmakerange (one, ten)];label.attributedtext = TEXTLABELSTR;  

3.font: Sets the label text font.

By default, the system comes with a font size of 17.

Label.font = [Uifont Systemfontofsize:17]label.font = [Uifont fontwithname:@ "Arial" size:16];  Label.textcolor = [Uicolor Bluecolor];
4.textAlignment: Sets the label text alignment.
Label.textalignment = Nstextalignmentcenter;  
5.lineBreakMode: Set the way the label text is displayed too long, this property is used in the word wrapping and truncation of the Chinese label. First, the NumberOfLines must be set to 0 to have an effect.

iOS code  Label.linebreakmode = nslinebreakbycharwrapping, displayed in characters, omitted in later sections.  Label.linebreakmode = nslinebreakbyclipping; Cuts the length of content with the same width as the text, and the latter part is deleted.  Label.linebreakmode = Nslinebreakbytruncatinghead; The front part of the text with ... method is omitted, displaying the trailing text content.  Label.linebreakmode = nslinebreakbytruncatingmiddle; the middle content with ... The method is omitted, showing the text content of the kinsoku.  Label.linebreakmode = Nslinebreakbytruncatingtail; the end of the content with ... Method omitted to display the text content of the header.  Label.linebreakmode = nslinebreakbywordwrapping; Displays the word as the display unit, and the latter part is omitted from the display.  For example: label.numberoflines = 0label.linebreakmode = Nslinebreakbytruncatingmiddle;

Implementation results:

6.enabled: Sets whether the text content is variable. 7.adjustsFontSizeToFitWidth: Text content Adaptive label width. 8.adjustsLetterSpacingToFitWidth: Adapts the width of the label according to the spacing of the letters, beyond the part to ... Show. 9.numberOfLines: Labels display up to a maximum number of rows. 10.minimumScaleFactor: Set the minimum font, same as minimumfontsize, Minimumfontsize is not available after iOS 6. 11.highlightedTextColor: Set the text highlighting color to use with highlighted. 12.shadowColor: Sets the text shadow color. 13.shadowColor: Sets the offset of the text shadow from the original text. Label.shadowoffset = Cgsizemake (1.0, 5.0);
14.userInteractionEnabled: Sets whether the label ignores or removes user interaction. The default is No. 15.preferredMaxLayoutWidth: Prioritizes the maximum width of the label layout. 16.baselineAdjustment: If the Adjustsfontsizetofitwidth property is set to Yes, this property controls the behavior of the text baseline.
Label4.baselineadjustment = Uibaselineadjustmentnone;  Uibaselineadjustmentalignbaselines=0, by default, aligns the top of the text with the centerline.  Uibaselineadjustmentaligncenters, the   middle of the text is aligned with the label centerline.  Uibaselineadjustmentnone, the  lowest end of the text is aligned with the label centerline.

BackgroundColor background Color

iOS code: Clear Background color

Label1.backgroundcolor = [Uicolor Clearcolor];

Common Properties for iOS text

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.