lable上显示不同的字体颜色


+(void)SetWithLabel:(UILabel *)label FontNumber:(id)font AndRange:(NSRange)aRange AndColor:(UIColor *)aColor
{
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:label.text];
    //设置字号
    [str addAttribute:NSFontAttributeName value:font range:aRange];
    //设置文字颜色
    [str addAttribute:NSForegroundColorAttributeName value:aColor range:aRange];
    label.attributedText = str;
}


你可能感兴趣的:(ios,lable,字体颜色)