iOS -字符串替换 富文本的简单使用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Dancer2015/article/details/50546869

NSString *skills = [userAcc.skills stringByReplacingOccurrencesOfString:@"$$" withString:@""];

   if ([skills length] > 0) {

        skills = [skills substringWithRange:NSMakeRange(0, [skills length]-1)];

    }

    cell.remarkLab.text = [NSString stringWithFormat:@"擅长领域:%@",skills];

    NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:cell.remarkLab.text];

    [attr addAttributes:@{NSForegroundColorAttributeName:EHMO_COLOR_GREEN} range:NSMakeRange(5, [cell.remarkLab.text length]-5)];

    cell.remarkLab.attributedText = attr;

阅读更多
换一批

没有更多推荐了,返回首页