私のコードで TTTAttributedLabel を使用する:
NSString *contentText = @"some text here foo bar";
[self.content setText:contentText afterInheritingLabelAttributesAndConfiguringWithBlock:^NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) {
return mutableAttributedString;
}];
self.content.linkAttributes = @{ NSForegroundColorAttributeName: [UIColor redColor],
NSUnderlineStyleAttributeName: [NSNumber numberWithInt:NSUnderlineStyleSingle] };
NSRange range = [self.content.text rangeOfString:@"foo bar"];
[self.content addLinkToURL:[NSURL URLWithString:@"action://load-foo"] withRange:range];
[self.content setNeedsDisplay];
範囲テキストをタップしてアクションを実行するという点では、すべてが完全に機能しますが、機能していないように見えるのはテキストの色だけです. NSForegroundColorAttributeName
ライブラリで正しく使用していますか?
編集:
「機能しない」ということは、下線付きのテキストがグレーのままで、上で設定したように赤ではないということです。