次のコードでラベルに多色を使用するために TTAtributedLabel ライブラリを使用しています。
[lifeEventLabel setText:tempString afterInheritingLabelAttributesAndConfiguringWithBlock:^(NSMutableAttributedString *mutableAttributedString) {
NSRange blueRage = [tempString rangeOfString:[tempDict valueForKeyPath:@"person.firstName"]];
if (blueRage.location != NSNotFound) {
// Core Text APIs use C functions without a direct bridge to UIFont. See Apple's "Core Text Programming Guide" to learn how to configure string attributes.
[mutableAttributedString addAttribute:(NSString *)kCTForegroundColorAttributeName value:(id)[UIColor blueColor].CGColor range:blueRage];
}
return mutableAttributedString;
}];
私の問題は、次のヘッダーファイルで一定のUIColorを取得したことです
#define TEXT_LINK_COLOR [UIColor colorWithRed:(68/255.0) green:(110/255.0) blue:(126/255.0) alpha:1];
しかし、今の問題は、次の方法でアクセスして、uilabelの文字列の一部に上記の色を与えることができないことです
[mutableAttributedString addAttribute:(NSString *)kCTForegroundColorAttributeName value:(id)[UIColor blueColor].CGColor range:blueRage];
[UIColor blueColor].CGColor
それで、今すぐコンパイルエラーが発生するため、上記の行で上記の一定の色を代わりに使用する方法を教えてもらえますか?