我在我的项目中使用 TTTAttributedLabel。我只有一个大文本,我必须在 uilabel 中显示。在一定数量的行之后,如果文本被截断,则应该有“更多”文本。一切正常,但当我点击链接时,链接似乎有时会添加到截断文本之前的字符中 - 因此点击截断文本不会执行任何操作。任何人都可以帮助我,因为我需要尽快解决这个问题。
let truncatedStringColour = [
NSForegroundColorAttributeName: UIColor(red: 142.0/255.0, green: 59.0/255.0, blue: 84.0/255.0, alpha: 1.0),
NSFontAttributeName: UIFont(name: "DINRoundOT", size: 17.0)!,
NSLinkAttributeName : "link"
]
truncatedString = NSAttributedString(string: "...more", attributes: truncatedStringColour)
if let truncatStr = truncatedString {
cell.lblDescription.attributedTruncationToken = truncatStr
}
最佳答案
Docs说:
TTTAttributedLabel
can display both plain and attributed text: just pass anNSString
orNSAttributedString
to thesetText:
setter. Never assign to theattributedText
property.
要解决此问题,请设置标签的 text
属性而不是 attributed Text
属性。
检查这个answer
您可以使用 this为您提供更多帮助。
关于ios - TTTAttributedLabel 截断文本问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37644079/