Common attributes of ios text and ios text

Source: Internet
Author: User

Common attributes of ios text and ios text
1. text: Set the label to display text. 2. attributedText: Set the label attribute text.

NSString *text = @"first";  NSMutableAttributedString *textLabelStr = [[NSMutableAttributedString alloc] initWithString:text];  [textLabelStr setAttributes:@{                               NSForegroundColorAttributeName : [UIColor lightGrayColor],                                  NSFontAttributeName : [UIFont systemFontOfSize:17]                             } range:NSMakeRange(11, 10)];label.attributedText = textLabelStr;  

 

3. font: Set the label text font.

The default font is 17.

label.font = [UIFont systemFontOfSize:17]label.font = [UIFont fontWithName:@"Arial" size:16];  label.textColor = [UIColor blueColor];
4. textAlignment: sets the label text alignment mode.
label.textAlignment = NSTextAlignmentCenter;  
5. lineBreakMode: sets the display mode when the label text is too long. This attribute is used for line feed and truncation of text in the label. First, numberofLines must be set to 0 to be effective.

 

Ios code label. lineBreakMode = NSLineBreakByCharWrapping; it is displayed in characters and is not displayed in the subsequent parts. Label. lineBreakMode = NSLineBreakByClipping; cut the content length that is the same as the text width, and delete the second half. Label. lineBreakMode = NSLineBreakByTruncatingHead; the text above is ...... To display the text at the end. Label. lineBreakMode = NSLineBreakByTruncatingMiddle; the content in the middle is ...... To display the text at the beginning and end. Label. lineBreakMode = NSLineBreakByTruncatingTail ...... To display the text content of the header. Label. lineBreakMode = NSLineBreakByWordWrapping; displayed in the unit of words. The latter part is omitted and not displayed. For example, label. numberOfLines = 0label. lineBreakMode = NSLineBreakByTruncatingMiddle;

Effect:

6. enabled: Set whether the text content is variable. 7. adjustsFontSizeToFitWidth: Adaptive label width of text content. 8. adjustsLetterSpacingToFitWidth: Adaptive label width based on the letter interval. the excess part is ...... Display. 9. numberOfLines: the maximum number of lines displayed for a tag. 10. minimumScaleFactor: Set the smallest font, which is the same as minimumFontSize. minimumFontSize cannot be used after IOS 6. 11. highlightedTextColor: Set the highlighted color of the text, which is used with highlighted. 12. shadowColor: Set the text shadow color. 13. shadowColor: Set the offset between the text shadow and the original text. Label. shadowOffset = CGSizeMake (1.0, 5.0 );
14. userInteractionEnabled: sets whether to ignore or remove user interaction tags. The default value is NO. 15. preferredMaxLayoutWidth: the maximum width of the label layout is prioritized. 16. baselineAdjustment: If the adjustsFontSizeToFitWidth attribute is set to YES, this attribute controls the behavior of the text baseline.
Label4.baselineAdjustment = UIBaselineAdjustmentNone; UIBaselineAdjustmentAlignBaselines = 0. By default, the top part of the text is aligned with the midline. UIBaselineAdjustmentAlignCenters. The text midline is aligned with the label midline. UIBaselineAdjustmentNone. the lowest part of the text is aligned with the label midline.

 

17. backgroundColor background color

Ios code: Clear the background color

label1.backgroundColor = [UIColor clearColor];

 

 

 

Related Article

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.