我有一个 TTTAttributedLabel 并为它指定了一个自定义属性截断标记:
NSAttributedString *atributedTruncationToken = [[[NSAttributedString alloc]
initWithString:@" More..."
attributes:@{
NSForegroundColorAttributeName : [UIColor lightGrayColor],
NSFontAttributeName : self.messageLabel.font,
NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType // no effect
}] autorelease];
[self.messageLabel setAttributedTruncationToken:atributedTruncationToken];
它看起来很完美,但我怎样才能使令牌可点击?
(特别是,当用户单击令牌时,我需要扩展标签,而不是标签的其余部分)。
更新。 正如我所发现的,可以(iOS 7+)添加指向令牌的链接,如下所示:
NSAttributedString *atributedTruncationToken = [[[NSAttributedString alloc]
initWithString:@" More..."
attributes:@{
NSForegroundColorAttributeName : [UIColor lightGrayColor],
NSFontAttributeName : self.messageLabel.font,
NSLinkAttributeName : [NSURL URLWithString:@"..."]
}] autorelease];
但是 TTTAttributed 标签中存在一种错误(?),令牌仍然无法点击,但n = token length
标签文本的最后 n ( ) 个字符可以!