Using NSMutableAttributedString to achieve label font size, color, line spacing changes

UILabel*label = [[UILabelalloc]initWithFrame:CGRectMake (0,0, self.frame.size.width, self.frame.size.height)];

The use of n is the font display / slash two lines

Label.text=@ “quiz /n (after the completion of learning, to test the label.font= [UIFontsystemFontOfSize:10])”;

Don’t forget / / use the newline symbol to write this sentence

Label.numberOfLines=0; label.textColor= [UIColorhexChangeFloat:@; “A5A5A5”];

Using attribute string font size / color

NSMutableAttributedString*AttributedStr = [[NSMutableAttributedStringalloc]initWithString:label.text]; [AttributedStraddAttribute:NSForegroundColorAttributeName value:[HuConfigrationuiColorFromString:@ “#D3D3D3” range:NSMakeRange (0,4)]];

[AttributedStraddAttribute:NSFontAttributeName, value:[UIFontcustomFontSize:18], range:NSMakeRange (0,4)];

/ / modify line spacing

NSMutableParagraphStyle*paragraphStyle = [[NSMutableParagraphStylealloc]init]; [paragraphStylesetLineSpacing:4]; [AttributedStraddAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange (0, [label.textlength]); label.attributedText= AttributedStr; label.textAlignment=NSTextAlignmentCenter; [selfaddSubview:label];

Design sketch´╝Ü

Using NSMutableAttributedString to achieve label font size, color, line spacing changes