<分区>
我正在用 Swift 4.0 更新我的源代码我面临以下与属性文本相关的问题
以下代码在 swift 3.2 中运行良好。
entemessageText.highlightTapAction = { (containerView: UIView, text: NSAttributedString, range: NSRange, rect: CGRect) -> () in
let attributes = text.attributes(at: range.location, effectiveRange: nil)
if let attrs = attributes["YYTextHighlight"] as? YYTextHighlight {
if let url = attrs.userInfo!["url"] as? String {
self.openUrl(URL(string: url)!)
}
}
}
“无法使用类型为‘String’的索引下标类型为‘[NSAttributedStringKey:Any]’的值”
我用相同的关键字搜索解决方案,但没有得到任何结果。
任何帮助或建议都会有所帮助。