ios 一个Label显示多行不同字体的文字
作者:互联网
`UILabel *lbl = [[UILabel alloc]init];
NSString *text =@"你好\n哈哈哈";
NSMutableAttributedString *attributeText = [[NSMutableAttributedString alloc]initWithString:text];
[attributeText addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:17] range:NSMakeRange(0, text.length)];
[attributeText addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, text.length)];
[attributeText addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:24] range:NSMakeRange(3, 3)];
[attributeText addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(3, text.length - 3)];
lbl.attributedText = attributeText;
lbl.numberOfLines = 0;
lbl.textAlignment = NSTextAlignmentCenter;
lbl.frame = CGRectMake(0, 200, 100, 100);
[self.view addSubview:lbl];
`
标签:多行,attributeText,text,ios,value,Label,NSMakeRange,addAttribute,lbl 来源: https://www.cnblogs.com/Johnson-Swift/p/15770325.html