user246392
user246392

Reputation: 3009

Xamarin: Change auto detected link color in UITextView and keep the underline

In Xamarin.iOS, how does one change the text color of the auto detected links in a UITextView and still keep the underline?

Currently, I have the following:

_textView = new UITextView
{
     Editable = false,
     DataDetectorTypes = UIDataDetectorType.Link,
     ScrollEnabled = false
};

If I set the TintColor on the UITextView, then the link color changes but the underline is removed from the link. I'd like to keep the underline as well.

Upvotes: 2

Views: 142

Answers (1)

Lucas Zhang
Lucas Zhang

Reputation: 18861

You could set the Attribute style of TextView

var linkColr= UIStringAttributeKey.ForegroundColor;
var value1 = UIColor.Red;

var linkStyle= UIStringAttributeKey.UnderlineStyle;
var value2 = new NSNumber(1);

var dic = new NSDictionary(linkColr, value1, linkStyle, value2);
_textView .WeakLinkTextAttributes = dic;

Upvotes: 1

Related Questions