改变字符串颜色从哪里开始截取改变颜色

  NSString * pricstr=@"价格:";

    _pricelable.text = [NSString stringWithFormat:@"%@%@",pricstr,drawmodel.shop_price];

    //改变字符串颜色

    NSMutableAttributedString *textColor = [[NSMutableAttributedString alloc]initWithString:_pricelable.text];

    NSRange rangel = [[textColor string] rangeOfString:[_pricelable.text substringFromIndex:3]];

    [textColor addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:rangel];

    [textColor addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15] range:rangel];

    [_pricelable setAttributedText:textColor];

posted @ 2017-12-05 09:50  whx060900  阅读(235)  评论(0编辑  收藏  举报