I have the following code but my links are always blue. How do I cange the color of them?
[_string addAttribute:NSLinkAttributeName value:tag range:NSMakeRange(position, length)];
[_string addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:(12.0)] range:NSMakeRange(position, length)];
[_string addAttribute:NSStrokeColorAttributeName value:[UIColor greenColor] range:NSMakeRange(position, length)];
_string is a NSMutableAttributedString and the position and length work fine.
Swift
Updated for Swift 4.2
Use
linkTextAttributes
with aUITextView
And in context:
Objective-C
Use
linkTextAttributes
with aUITextView
Source: this answer
And from this post:
The link color is the tint color of the label/textView. So, you can change it by changing the tint color of the view. However, this will not work if you want different link colours within the same view.
Swift
Objective-C
This will make underlined white clickable text. Select necessary attributes for your code and use it.
To have string with clickable link in it do next:
As a result you will get string 'Click here' and 'here' will be a link. You can set different styles to each string.
For swift3.0