I have to display a small portion of a long text in objective C.how we will use TTTAttributedLabel to add a Read More button to display all text.
Thanks in advance
I have to display a small portion of a long text in objective C.how we will use TTTAttributedLabel to add a Read More button to display all text.
Thanks in advance
NSLinkAttributeName
: [NSURL URLWithString:EXTagURL]
.Then use the delegate method below to navigate to the URL of the attributed string you set.
-(void)attributedLabel:(TTTAttributedLabel *)label
didSelectLinkWithURL:(NSURL *)url{}
Hope this helps.
Firstly make sure you have updated cocoapods In your terminal:- gem install cocoapods , pod install
Then set the label to class TTTAttributed label in your storyboard. Then create an outlet to your view controller @property (weak, nonatomic) IBOutlet TTTAttributedLabel *articleDetail;
Then create an attributed string in viewdidload
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"Read More .."];
[attributedString addAttribute: NSLinkAttributeName value: [NSURL URLWithString:@""] range: NSMakeRange(0, attributedString.length)];
self.articleDetail.attributedTruncationToken = attributedString;
Then finally create delegate method
-(void)attributedLabel:(TTTAttributedLabel *)label
didSelectLinkWithURL:(NSURL *)url
{
}