I'm using code provided in this answer to create a dynamic label and it works for the most part. But whenever the label text goes over 94 characters in length it gets truncated and ellipsis' are added.
There is one more odd thing about this is that if I add more characters to the string they are shown but the last 2 lines are still truncated.
Eg.
The string:
this is a very very long string
with lots of words to test the
dynamic bubble sizing one two three.
shows up like this:
this is a very very long string
with lots of words to test the
dynamic bubble sizing one tw...
But when I double the string by using the same sentence again in the label it show more of te text but still truncates it.
Eg.
The string:
this is a very very long string
with lots of words to test the
dynamic bubble sizing one two
three. this is a very very long
string with lots of words to test
the dynamic bubble sizing one
two three.
shows like this:
this is a very very long string
with lots of words to test the
dynamic bubble sizing one two
three. this is a very very long
string with lots of words to tes...
Here's the code I'm using.
NSString *temp = [NSString stringWithFormat:@"this is a very very long string with lots of words to test the dynamic bubble sizing one two three"];
captionLabel.text = temp;
//Calculate the expected size based on the font and linebreak mode of your label
CGSize maximumLabelSize = CGSizeMake(296,9999);
CGSize expectedLabelSize = [temp sizeWithFont:captionLabel.font
constrainedToSize:maximumLabelSize
lineBreakMode:captionLabel.lineBreakMode];
//adjust the label the the new height.
CGRect newFrame = captionLabel.frame;
newFrame.size.height = expectedLabelSize.height;
captionLabel.frame = newFrame;
Hope someone has an idea because this has me scratching my head.
EDIT
Using captionLabel.frame.size.width instead of hard-coded 296 fixed it, thanks to @troolee, if he/she chooses to create an answer I will mark it correct.