Sets the property settings for certain specified fonts in the label (Color,size,fontcolor)

Source: Internet
Author: User

Do not know if you have encountered to set some font color and size properties such as settings, let us go into the font of the transformation of the kingdom!!!

1. Drag a control label in storyboard, drag the Line setting property to:

@property (Weak, nonatomic) Iboutlet UILabel *easylabel;

2. Set the properties in Viewdidload:

The main use of a key word is attribute, see the following code:

- (void) viewdidload {[Super viewdidload];

Attribute: Properties//The following two exist simultaneously, and the second one works.//Self . Easylabel.attributedtext = [[nsattributedstring alloc]initwithstring:@ "When the ling, at a glance at the mountain Small"];//Self . Easylabel.text = @ "Summer";the//Label property is set Nsmutableattributedstring*STR = [[nsmutableattributedstring alloc]initwithstring:@"parking and sitting love Maple night, double J.R. Cole and the Flowers"]; //size[Str addattribute:nsfontattributename value:[uifont systemfontofsize: +] Range:nsmakerange (8,7)];//Background Color[Str addattribute:nsbackgroundcolorattributename value:[uicolor Yellowcolor] Range:nsmakerange (7,7)];//Font Color[Str addattribute:nsforegroundcolorattributename value:[uicolor Purplecolor] Range:nsmakerange (4,8)]; Self. Easylabel.attributedtext=str; }

Sets the property settings for certain specified fonts in the label (Color,size,fontcolor)

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.