Utwórz link w UILabel.attributedText * nie * niebieski i * nie * podkreślony

Chcę, aby niektóre słowa w moim OHAttributLabel były linkami, ale chcę, żeby były to kolory inne niż niebieskie i nie chcę podkreślenia.

To daje mi niebieski link z podkreślonym tekstem:

 -(void)createLinkFromWord:(NSString*)word withColor:(UIColor*)color atRange:(NSRange)range{

    NSMutableAttributedString* mutableAttributedText = [self.label.attributedText mutableCopy];   

    [mutableAttributedText beginEditing];
    [mutableAttributedText addAttribute:kOHLinkAttributeName
                   value:[NSURL URLWithString:@"http://www.somewhere.net"]
                   range:range];

    [mutableAttributedText addAttribute:(id)kCTForegroundColorAttributeName
                   value:color
                   range:range];

    [mutableAttributedText addAttribute:(id)kCTUnderlineStyleAttributeName
                   value:[NSNumber numberWithInt:kCTUnderlineStyleNone]
                   range:range];
    [mutableAttributedText endEditing];


    self.label.attributedText = mutableAttributedText;

}

Ponieważ używam OHAttributedLabel, próbowałem również użyć metod w nimNSAttributedString+Attributes.h kategoria, ale zwracają również niebieskie podkreślone linki:

-(void)createLinkFromWord:(NSString*)word withColor:(UIColor*)color atRange:(NSRange)range{

NSMutableAttributedString* mutableAttributedText = [self.label.attributedText mutableCopy];

[mutableAttributedText setLink:[NSURL URLWithString:@"http://www.somewhere.net"] range:range];
[mutableAttributedText setTextColor:color range:range];
[mutableAttributedText setTextUnderlineStyle:kCTUnderlineStyleNone range:range];

self.label.attributedText = mutableAttributedText;
}

Jeśli skomentuję linię ustawiającą linki w każdej wersji, tekst staje się kolorowy do tego, co przekazuję - to działa. Wygląda na to, że ustawienie łącza przesłania to i przywraca kolor niebieski.

Niestety strona z dokumentami jabłko, którą znalazłem, pokazuje, jak ustawić tekst łącza na niebieski i podkreślić go, dokładnie to, czego nie potrzebuję:https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/AttributedStrings/Tasks/ChangingAttrStrings.html

questionAnswers(11)

yourAnswerToTheQuestion