I have a TTTAttributedLabel and specified a custom attributed truncation token for it:
NSAttributedString *atributedTruncationToken = [[[NSAttributedString alloc]
initWithString:@" More..."
attributes:@{
NSForegroundColorAttributeName : [UIColor lightGrayColor],
NSFontAttributeName : self.messageLabel.font,
NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType // no effect
}] autorelease];
[self.messageLabel setAttributedTruncationToken:atributedTruncationToken];
It looks perfect, but how can I make the token clickable?
(Particularly, I need the label to expand when user clicks on the token, but not on the rest of the label).
UPDATE. As I have found out, it is possible (iOS 7+) to add a link to the token, like the follows:
NSAttributedString *atributedTruncationToken = [[[NSAttributedString alloc]
initWithString:@" More..."
attributes:@{
NSForegroundColorAttributeName : [UIColor lightGrayColor],
NSFontAttributeName : self.messageLabel.font,
NSLinkAttributeName : [NSURL URLWithString:@"..."]
}] autorelease];
But there is kind of a bug (?) in TTTAttributed label, that the token still does not became clickable, but the n (n = token length
) last characters of the label's text do!
ResponsiveLabel, a subclass of UILabel can be used to configure clickable truncation token.