1

我想根据“ TTTAttributedLabel ”的第三部分库更改文本颜色,但这没有意义。这是我的代码:

 TTTAttributedLabel *priceInfoLabel.frame = [[TTTAttributedLabel alloc] initWithFrame:CGRectMake(self.view.width-12-realSize.width-priceSize.width, 15, realSize.width+priceSize.width, 18)];

priceInfoLabel.centerY = nameView.height/2;
priceInfoLabel.textColor = kRealPriceColor;
[priceInfoLabel setText:[NSString stringWithFormat:@"%@%@",realPriceText,priceText] afterInheritingLabelAttributesAndConfiguringWithBlock:^NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) {
    NSRange priceStringRange = [[mutableAttributedString string] rangeOfString:priceText options:NSCaseInsensitiveSearch];
    [mutableAttributedString addAttribute:NSFontAttributeName value:[UIFont fontWithName:nil size:12] range:priceStringRange];
    [mutableAttributedString addAttribute:UITextAttributeTextColor
                                    value:colorWithIntegerValue(195, 195, 195) range:priceStringRange];
    return mutableAttributedString;
}];
4

1 回答 1

2

尝试使用:

[mutableAttributedString addAttribute:(NSString *)kCTForegroundColorAttributeName
                                    value:colorWithIntegerValue(195, 195, 195) range:priceStringRange];
于 2014-10-29T17:04:35.050 回答