+ (NSMutableAttributedString *) transCurrentStr:(NSString *)currentString;
{
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:currentString];
[str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15] range:NSMakeRange(0,str.length)];
//设置固定范围字体颜色不同
[str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(1,str.length)];
//在字符串中间划横线
[str addAttribute:NSStrikethroughStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleThick] range:NSMakeRange(0, str.length)];
// 调整行间距
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:6];
[str addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [str length])];
return str;}
富文本的使用(让字符串特定字符颜色不同和在字符串上划横线)
最新推荐文章于 2024-09-14 18:52:56 发布