gpt4 book ai didi

ios - xamarin.ios 上的 UITextViewL 链接

转载 作者:行者123 更新时间:2023-11-29 00:28:25 26 4
gpt4 key购买 nike

我有一个自定义的 UITextView 并需要这样的东西:

<a href="www.google.es">Google</a>

顺便说一句,这是我在自定义类上的初始化代码:

void Initialize()
{
Font = UIFont.FromName("Lacuna Regular", 14f);
Editable = false;
DataDetectorTypes = UIDataDetectorType.Link;
Text = "Google";
}

但我不知道如何编写我需要去的网址(在本例中为 www.google.es)。

提前致谢!

最佳答案

通过UIDataDetectorType.Links:

uiview.DataDetectorTypes = UIDataDetectorType.Link;
uiview.Text = @"https://www.google.es";

enter image description here

通过 NSAttributedStringDocumentAttributesNSAttributedString:

var urlString = @"<a href=""https://www.google.es"">Google</a>";
var documentAttributes = new NSAttributedStringDocumentAttributes { DocumentType = NSDocumentType.HTML };
NSError error = null;
var attributedString = new NSAttributedString(NSData.FromString(urlString, NSStringEncoding.UTF8), documentAttributes, ref error);
// Should really check the NSError before applying
uiview.AttributedText = attributedString;

enter image description here

关于ios - xamarin.ios 上的 UITextViewL 链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42468038/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com