在Xamarin.iOS中,如何更改UITextView
中自动检测到的链接的文本颜色并仍然保持下划线?
当前,我有以下内容:
_textView = new UITextView
{
Editable = false,
DataDetectorTypes = UIDataDetectorType.Link,
ScrollEnabled = false
};
如果我将TintColor
设置为UITextView
,则链接颜色会更改,但下划线将从链接中删除。我也想保留下划线。
您可以设置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;