gpt4 book ai didi

ios - 超链接到 uitextview 中的文本部分

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

我正在尝试在 UITextView 上设置“常见问题解答”部分。如何链接 UITextView 上的一行文本,以便当用户单击它时,UITextView 滚动到同一 View 中的一段文本。我还想在文本下划线并将文本颜色更改为蓝色。

最佳答案

尝试 TTTAttributedLabel

TTTAtributedLabel 允许您自动检测日期、地址、链接、电话号码、交通信息的链接,或者允许您嵌入自己的链接

label.enabledTextCheckingTypes = NSTextCheckingTypeLink; // Automatically detect links when the label text is subsequently changed
label.delegate = self; // Delegate methods are called when the user taps on a link (see `TTTAttributedLabelDelegate` protocol)

label.text = @"Fork me on GitHub! (http://github.com/mattt/TTTAttributedLabel/)"; // Repository URL will be automatically detected and linked

NSRange range = [label.text rangeOfString:@"me"];
[label addLinkToURL:[NSURL URLWithString:@"http://github.com/mattt/"] withRange:range]; // Embedding a custom link in a substring

关于ios - 超链接到 uitextview 中的文本部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27059035/

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