NSMutableAttributedString 的使用

NSMutableAttributedString *msAttriStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"this is book ",departmentStr,departmentStatistics.d_count]];

    //设置字体大小

    [msAttriStr addAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:18.0f]} range:NSMakeRange(0,length];

    //设置字体颜色

    [msAttriStr addAttributes:@{NSForegroundColorAttributeName:[UIColor redColor]} range:NSMakeRange(0, length)];

原文地址:https://www.cnblogs.com/uwking/p/5030957.html