RTLabel icon indicating copy to clipboard operation
RTLabel copied to clipboard

Calculate Size

Open flodev03 opened this issue 11 years ago • 3 comments

Hi honcheng,

first of all i want to thank you about this amazing label you give us.

I'm using RTLabel in my new app, everything is cool, great features, nice behavior...

I only have one thing that is making me lose my mind : how to calculate the size of the RTLabel depending on NSString ?

I use a CGConstraint to calculate the height of the label based on the RTLabel's text (NSString) but sometimes it is longer, sometimes shorter... can't have the real size.

How can i do this ?

thanks.

Ps : maybe you should add a donation button using paypal.

flodev03 avatar Mar 26 '13 10:03 flodev03

FWIW, I am having this problem as well. I need to show multiple RTLabels below each other in a view, but am unable to control the label placements because I cannot get an accurate height reading. At this point it looks like I have no choice but to abandon using RTLabel and instead using regular UILabels without the text formatting :-(

vanderneut avatar Mar 27 '14 01:03 vanderneut

I get the height for RTLabel by calling [myRTLabel setNeedsDisplay] after setting the text then getting the height like so myRTLabel.optimumSize.height

kdaker avatar Mar 27 '14 01:03 kdaker

I had the same issue, found solution after initialization of RTlLabel with frame of height 100.

RTLabel *yourLabel = [[RTLabel alloc] initWithFrame:CGRectMake(0,0,100,100)]; then assign text n get optimize height and update frame of yourLabel.

adnanbajwa avatar Mar 18 '15 06:03 adnanbajwa