Reputation: 307
i want to change the text color based on the 3rd part lib which is "TTTAttributedLabel" , but it does not make sense. Here is my code:
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;
}];
Upvotes: 1
Views: 465
Reputation: 7312
Try using:
[mutableAttributedString addAttribute:(NSString *)kCTForegroundColorAttributeName
value:colorWithIntegerValue(195, 195, 195) range:priceStringRange];
Upvotes: 2