Reputation: 4617
I am using TTTAttributedLabel but now when i try to show some link then it cut the word from the center like you can see in attached image the word "fun" is cut off after word "f" and "un" appears on next line. but i want that the full word should show on first line or in next line. Any help.
if ([_label isKindOfClass:[TTTAttributedLabel class]])
{
TTTAttributedLabel *tttLabel=(TTTAttributedLabel *)_label;
[tttLabel setDelegate:self];
[tttLabel setDataDetectorTypes:UIDataDetectorTypeLink|UIDataDetectorTypePhoneNumber];
[tttLabel setLineBreakMode:NSLineBreakByWordWrapping];
[tttLabel setText:attributedText];
if ([dic objectForKey:@"texttolink"]!=nil)
{
[tttLabel addLinkToURL:[NSURL URLWithString:[dic objectForKey:@"hyperlink"]] withRange:[text rangeOfString:[dic objectForKey:@"texttolink"] options:NSCaseInsensitiveSearch]];
}
}
Upvotes: 2
Views: 1405
Reputation: 19544
In the latest version of TTTAttributedLabel, the default linkAttributes
property was updated to have word wrap by default. Make sure that both the label and the linkAttributes
have the desired line break mode (lineBreakMode
property for the label; NSMutableParagraphStyle lineBreakMode
for linkAttributes
).
Upvotes: 3
Reputation: 9944
Try setting lineBreakMode
to NSLineBreakByWordWrapping
:
label.lineBreakMode = NSLineBreakByWordWrapping;
Upvotes: 1