IOS中一段文字设置多种字体颜色代码
给定range和需要设置的颜色,就可以给一段文字设置多种不同的字体颜色,使用方法如下:
[selffuwenbenLabel:contentLabelFontNumber:[UIFontsystemFontOfSize:15]AndRange:NSMakeRange(6,1)AndColor:RGBACOLOR(34,150,253,1)];
//设置不同字体颜色
-(void)fuwenbenLabel:(UILabel*)labellFontNumber:(id)fontAndRange:(NSRange)rangeAndColor:(UIColor*)vaColor
{
NSMutableAttributedString*str=[[NSMutableAttributedStringalloc]initWithString:labell.text];
//设置字号
[straddAttribute:NSFontAttributeNamevalue:fontrange:range];
//设置文字颜色
[straddAttribute:NSForegroundColorAttributeNamevalue:vaColorrange:range];
labell.attributedText=str;
}
以上所述就是本文的全部内容了,希望大家能够喜欢。
热门推荐
10 新年门口花束祝福语简短
11 盘锦结婚祝福语大全简短
12 父母生日祝福语 简短独特
13 家庭恩爱祝福语简短英文
14 高考俄语祝福语大全简短
15 虎年祝福语 诗句唯美简短
16 生日婚礼祝福语简短精辟
17 虎年喝酒拜年祝福语简短
18 教师闺蜜祝福语简短