Reputation: 700
As per title above, did anyone ever face this problem when using TTTAttributedLabel?
Currently, if the label display only 1 line, it won't show up from the app. But if the labels size is more than 1 line, it working fine.
Is there anyone ever come across with this problem/bug? Hope this can help others also, thanks!
Upvotes: 2
Views: 3002
Reputation: 5145
Based on these two posts:
It would seem that there is a problem with how CoreText measures height, and what is actually rendered when drawing the text, when it is a single line.
What seems to be happening is that the text is present, but the window to draw the text is still too small. So the solution is to manually set the frame of the TTTAttributeLabel to something bigger than what sizeToFit gives.
This involves two steps:
Something like this would do it:
if (labelHeight < kSingleLineLabelHeight) {
labelHeight = kSingleLineLabelHeight
}
And then setting the label height accordingly.
Upvotes: 2